equalizer: enable presets for the n-band equalizer

Add a test for saving and restoring the preset.
This commit is contained in:
Stefan Sauer 2012-08-17 14:59:57 +02:00
parent 0d148d9c6f
commit 1f255a585b
4 changed files with 58 additions and 6 deletions

View file

@ -62,7 +62,8 @@ static GstFlowReturn gst_iir_equalizer_transform_ip (GstBaseTransform * btrans,
G_DEFINE_TYPE_WITH_CODE (GstIirEqualizer, gst_iir_equalizer, G_DEFINE_TYPE_WITH_CODE (GstIirEqualizer, gst_iir_equalizer,
GST_TYPE_AUDIO_FILTER, GST_TYPE_AUDIO_FILTER,
G_IMPLEMENT_INTERFACE (GST_TYPE_CHILD_PROXY, G_IMPLEMENT_INTERFACE (GST_TYPE_CHILD_PROXY,
gst_iir_equalizer_child_proxy_interface_init)); gst_iir_equalizer_child_proxy_interface_init)
G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
/* child object */ /* child object */
@ -348,7 +349,6 @@ gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface,
iface->get_children_count = gst_iir_equalizer_child_proxy_get_children_count; iface->get_children_count = gst_iir_equalizer_child_proxy_get_children_count;
} }
/* equalizer implementation */ /* equalizer implementation */
static void static void

View file

@ -63,8 +63,8 @@ GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
#define gst_iir_equalizer_10bands_parent_class parent_class #define gst_iir_equalizer_10bands_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstIirEqualizer10Bands, gst_iir_equalizer_10bands, G_DEFINE_TYPE (GstIirEqualizer10Bands, gst_iir_equalizer_10bands,
GST_TYPE_IIR_EQUALIZER, G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL)); GST_TYPE_IIR_EQUALIZER);
/* equalizer implementation */ /* equalizer implementation */

View file

@ -54,8 +54,8 @@ GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
#define GST_CAT_DEFAULT equalizer_debug #define GST_CAT_DEFAULT equalizer_debug
#define gst_iir_equalizer_3bands_parent_class parent_class #define gst_iir_equalizer_3bands_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstIirEqualizer3Bands, gst_iir_equalizer_3bands, G_DEFINE_TYPE (GstIirEqualizer3Bands, gst_iir_equalizer_3bands,
GST_TYPE_IIR_EQUALIZER, G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL)); GST_TYPE_IIR_EQUALIZER);
/* equalizer implementation */ /* equalizer implementation */

View file

@ -310,6 +310,57 @@ GST_START_TEST (test_equalizer_band_number_changing)
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_equalizer_presets)
{
GstElement *eq1, *eq2;
gint type;
gdouble gain, freq;
eq1 = gst_check_setup_element ("equalizer-nbands");
g_object_set (G_OBJECT (eq1), "num-bands", 3, NULL);
/* set properties to non-defaults */
gst_child_proxy_set ((GstChildProxy *) eq1,
"band0::type", 0, "band0::gain", -3.0, "band0::freq", 100.0,
"band1::type", 1, "band1::gain", +3.0, "band1::freq", 1000.0,
"band2::type", 2, "band2::gain", +9.0, "band2::freq", 10000.0, NULL);
/* save preset */
gst_preset_save_preset ((GstPreset *) eq1, "_testpreset_");
GST_INFO_OBJECT (eq1, "Preset saved");
eq2 = gst_check_setup_element ("equalizer-nbands");
g_object_set (G_OBJECT (eq2), "num-bands", 3, NULL);
/* load preset */
gst_preset_load_preset ((GstPreset *) eq2, "_testpreset_");
GST_INFO_OBJECT (eq1, "Preset loaded");
/* compare properties */
gst_child_proxy_get ((GstChildProxy *) eq2,
"band0::type", &type, "band0::gain", &gain, "band0::freq", &freq, NULL);
ck_assert_int_eq (type, 0);
fail_unless (gain == -3.0, NULL);
fail_unless (freq == 100.0, NULL);
gst_child_proxy_get ((GstChildProxy *) eq2,
"band1::type", &type, "band1::gain", &gain, "band1::freq", &freq, NULL);
ck_assert_int_eq (type, 1);
fail_unless (gain == +3.0, NULL);
fail_unless (freq == 1000.0, NULL);
gst_child_proxy_get ((GstChildProxy *) eq2,
"band2::type", &type, "band2::gain", &gain, "band2::freq", &freq, NULL);
ck_assert_int_eq (type, 2);
fail_unless (gain == +9.0, NULL);
fail_unless (freq == 10000.0, NULL);
gst_preset_delete_preset ((GstPreset *) eq1, "_testpreset_");
gst_check_teardown_element (eq1);
gst_check_teardown_element (eq2);
}
GST_END_TEST;
static Suite * static Suite *
equalizer_suite (void) equalizer_suite (void)
{ {
@ -321,6 +372,7 @@ equalizer_suite (void)
tcase_add_test (tc_chain, test_equalizer_5bands_minus_24); tcase_add_test (tc_chain, test_equalizer_5bands_minus_24);
tcase_add_test (tc_chain, test_equalizer_5bands_plus_12); tcase_add_test (tc_chain, test_equalizer_5bands_plus_12);
tcase_add_test (tc_chain, test_equalizer_band_number_changing); tcase_add_test (tc_chain, test_equalizer_band_number_changing);
tcase_add_test (tc_chain, test_equalizer_presets);
return s; return s;
} }