mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
tests/icles/equalizer-test.c: Port the example to new equalizer api.
Original commit message from CVS: * tests/icles/equalizer-test.c: (equalizer_set_band_value), (equalizer_set_all_band_values), (equalizer_set_band_value_and_wait), (equalizer_set_all_band_values_and_wait), (do_slider_fiddling), (main): Port the example to new equalizer api.
This commit is contained in:
parent
045440b483
commit
04a574c282
2 changed files with 36 additions and 36 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-03-14 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
|
* tests/icles/equalizer-test.c: (equalizer_set_band_value),
|
||||||
|
(equalizer_set_all_band_values),
|
||||||
|
(equalizer_set_band_value_and_wait),
|
||||||
|
(equalizer_set_all_band_values_and_wait), (do_slider_fiddling),
|
||||||
|
(main):
|
||||||
|
Port the example to new equalizer api.
|
||||||
|
|
||||||
2007-03-14 Edward Hervey <edward@fluendo.com>
|
2007-03-14 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
* sys/osxvideo/cocoawindow.h:
|
* sys/osxvideo/cocoawindow.h:
|
||||||
|
|
|
@ -62,47 +62,52 @@ check_bus (GstClockTime max_wait_time)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fix below
|
||||||
|
|
||||||
static void
|
static void
|
||||||
equalizer_set_band_value (GstElement * eq, GValueArray * arr, guint band,
|
equalizer_set_band_value (GstElement * eq, guint band, gdouble val)
|
||||||
gdouble val)
|
|
||||||
{
|
{
|
||||||
g_value_set_double (g_value_array_get_nth (arr, band), val);
|
GstObject *child;
|
||||||
g_object_set (eq, "band-values", arr, NULL);
|
|
||||||
|
child = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (eq), band);
|
||||||
|
g_object_set (child, "gain", val, NULL);
|
||||||
|
gst_object_unref (child);
|
||||||
g_print ("Band %2d: %.2f\n", band, val);
|
g_print ("Band %2d: %.2f\n", band, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
equalizer_set_all_band_values (GstElement * eq, GValueArray * arr, gdouble val)
|
equalizer_set_all_band_values (GstElement * eq, guint num, gdouble val)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
GstObject *child;
|
||||||
|
|
||||||
for (i = 0; i < arr->n_values; ++i) {
|
for (i = 0; i < num; i++) {
|
||||||
g_value_set_double (g_value_array_get_nth (arr, i), val);
|
child = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (eq), i);
|
||||||
|
g_object_set (child, "gain", val, NULL);
|
||||||
|
gst_object_unref (child);
|
||||||
}
|
}
|
||||||
g_object_set (eq, "band-values", arr, NULL);
|
|
||||||
g_print ("All bands: %.2f\n", val);
|
g_print ("All bands: %.2f\n", val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fix above
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
equalizer_set_band_value_and_wait (GstElement * eq, GValueArray * arr,
|
equalizer_set_band_value_and_wait (GstElement * eq, guint band, gdouble val)
|
||||||
guint band, gdouble val)
|
|
||||||
{
|
{
|
||||||
equalizer_set_band_value (eq, arr, band, val);
|
equalizer_set_band_value (eq, band, val);
|
||||||
return check_bus (100 * GST_MSECOND);
|
return check_bus (100 * GST_MSECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
equalizer_set_all_band_values_and_wait (GstElement * eq, GValueArray * arr,
|
equalizer_set_all_band_values_and_wait (GstElement * eq, guint num, gdouble val)
|
||||||
gdouble val)
|
|
||||||
{
|
{
|
||||||
equalizer_set_all_band_values (eq, arr, val);
|
equalizer_set_all_band_values (eq, num, val);
|
||||||
return check_bus (100 * GST_MSECOND);
|
return check_bus (100 * GST_MSECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_slider_fiddling (GstElement * playbin, GstElement * eq)
|
do_slider_fiddling (GstElement * playbin, GstElement * eq)
|
||||||
{
|
{
|
||||||
GValueArray *arr;
|
|
||||||
gboolean stop;
|
gboolean stop;
|
||||||
guint num_bands, i;
|
guint num_bands, i;
|
||||||
gdouble d, step = 0.2;
|
gdouble d, step = 0.2;
|
||||||
|
@ -113,54 +118,41 @@ do_slider_fiddling (GstElement * playbin, GstElement * eq)
|
||||||
|
|
||||||
g_print ("%u bands.\n", num_bands);
|
g_print ("%u bands.\n", num_bands);
|
||||||
|
|
||||||
arr = g_value_array_new (num_bands);
|
|
||||||
for (i = 0; i < num_bands; ++i) {
|
|
||||||
GValue val = { 0, };
|
|
||||||
|
|
||||||
g_value_init (&val, G_TYPE_DOUBLE);
|
|
||||||
g_value_set_double (&val, 0.0);
|
|
||||||
g_value_array_append (arr, &val);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_set (eq, "band-values", arr, NULL);
|
|
||||||
|
|
||||||
while (!stop) {
|
while (!stop) {
|
||||||
for (i = 0; !stop && i < num_bands; ++i) {
|
for (i = 0; !stop && i < num_bands; ++i) {
|
||||||
d = 0.0;
|
d = 0.0;
|
||||||
while (!stop && d <= 1.0) {
|
while (!stop && d <= 1.0) {
|
||||||
stop = equalizer_set_band_value_and_wait (eq, arr, i, d);
|
stop = equalizer_set_band_value_and_wait (eq, i, d);
|
||||||
d += step;
|
d += step;
|
||||||
}
|
}
|
||||||
d = 1.0;
|
d = 1.0;
|
||||||
while (!stop && d >= -1.0) {
|
while (!stop && d >= -1.0) {
|
||||||
stop = equalizer_set_band_value_and_wait (eq, arr, i, d);
|
stop = equalizer_set_band_value_and_wait (eq, i, d);
|
||||||
d -= step;
|
d -= step;
|
||||||
}
|
}
|
||||||
d = -1.0;
|
d = -1.0;
|
||||||
while (!stop && d <= 0.0) {
|
while (!stop && d <= 0.0) {
|
||||||
stop = equalizer_set_band_value_and_wait (eq, arr, i, d);
|
stop = equalizer_set_band_value_and_wait (eq, i, d);
|
||||||
d += step;
|
d += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d = 0.0;
|
d = 0.0;
|
||||||
while (!stop && d <= 1.0) {
|
while (!stop && d <= 1.0) {
|
||||||
stop = equalizer_set_all_band_values_and_wait (eq, arr, d);
|
stop = equalizer_set_all_band_values_and_wait (eq, num_bands, d);
|
||||||
d += step;
|
d += step;
|
||||||
}
|
}
|
||||||
d = 1.0;
|
d = 1.0;
|
||||||
while (!stop && d >= -1.0) {
|
while (!stop && d >= -1.0) {
|
||||||
stop = equalizer_set_all_band_values_and_wait (eq, arr, d);
|
stop = equalizer_set_all_band_values_and_wait (eq, num_bands, d);
|
||||||
d -= step;
|
d -= step;
|
||||||
}
|
}
|
||||||
d = -1.0;
|
d = -1.0;
|
||||||
while (!stop && d <= 0.0) {
|
while (!stop && d <= 0.0) {
|
||||||
stop = equalizer_set_all_band_values_and_wait (eq, arr, d);
|
stop = equalizer_set_all_band_values_and_wait (eq, num_bands, d);
|
||||||
d += step;
|
d += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_value_array_free (arr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -236,7 +228,7 @@ main (int argc, char **argv)
|
||||||
bin = gst_bin_new ("ausinkbin");
|
bin = gst_bin_new ("ausinkbin");
|
||||||
g_assert (bin != NULL);
|
g_assert (bin != NULL);
|
||||||
|
|
||||||
eq = gst_element_factory_make ("equalizer", "equalizer");
|
eq = gst_element_factory_make ("equalizer-nbands", "equalizer");
|
||||||
g_assert (eq != NULL);
|
g_assert (eq != NULL);
|
||||||
|
|
||||||
auconv = gst_element_factory_make ("audioconvert", "eqauconv");
|
auconv = gst_element_factory_make ("audioconvert", "eqauconv");
|
||||||
|
@ -250,7 +242,6 @@ main (int argc, char **argv)
|
||||||
if (!gst_element_link (auconv, sink))
|
if (!gst_element_link (auconv, sink))
|
||||||
g_error ("Failed to link audioconvert to audio sink");
|
g_error ("Failed to link audioconvert to audio sink");
|
||||||
|
|
||||||
|
|
||||||
eq_sinkpad = gst_element_get_static_pad (eq, "sink");
|
eq_sinkpad = gst_element_get_static_pad (eq, "sink");
|
||||||
g_assert (eq_sinkpad != NULL);
|
g_assert (eq_sinkpad != NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue