From f86bfaf5f90c42296de3f4dee8ec15a76f0f310c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 17 Aug 2007 14:43:33 +0000 Subject: [PATCH] gst/audiofx/: Use generator macros for the process functions for the different sample types, add lower upper boundari... Original commit message from CVS: * gst/audiofx/audiochebyshevfreqband.c: (gst_audio_chebyshev_freq_band_class_init): * gst/audiofx/audiochebyshevfreqlimit.c: (gst_audio_chebyshev_freq_limit_class_init): Use generator macros for the process functions for the different sample types, add lower upper boundaries for the GObject properties so automatically generated UIs can use sliders and add a note about the number of poles as a too high number of poles combined with very low or very high frequencies will produce only noise. * docs/plugins/gst-plugins-good-plugins.args: Regenerated for the property changes. --- ChangeLog | 14 +++++++ docs/plugins/gst-plugins-good-plugins.args | 18 ++++----- gst/audiofx/audiochebband.c | 59 +++++++++++++++--------------- gst/audiofx/audiocheblimit.c | 58 +++++++++++++++-------------- gst/audiofx/audiochebyshevfreqband.c | 59 +++++++++++++++--------------- gst/audiofx/audiochebyshevfreqlimit.c | 58 +++++++++++++++-------------- 6 files changed, 143 insertions(+), 123 deletions(-) diff --git a/ChangeLog b/ChangeLog index 399c534..808416d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-08-17 Sebastian Dröge + + * gst/audiofx/audiochebyshevfreqband.c: + (gst_audio_chebyshev_freq_band_class_init): + * gst/audiofx/audiochebyshevfreqlimit.c: + (gst_audio_chebyshev_freq_limit_class_init): + Use generator macros for the process functions for the different + sample types, add lower upper boundaries for the GObject properties + so automatically generated UIs can use sliders and add a note about + the number of poles as a too high number of poles combined with + very low or very high frequencies will produce only noise. + * docs/plugins/gst-plugins-good-plugins.args: + Regenerated for the property changes. + 2007-08-17 Wim Taymans * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_set_property), diff --git a/docs/plugins/gst-plugins-good-plugins.args b/docs/plugins/gst-plugins-good-plugins.args index 935e27b..57594bb 100644 --- a/docs/plugins/gst-plugins-good-plugins.args +++ b/docs/plugins/gst-plugins-good-plugins.args @@ -401,21 +401,21 @@ GstVertigoTV::speed gfloat -[0.01,100] +[0,01,100] rw Speed Control the speed of movement. -0.02 +0,02 GstVertigoTV::zoom-speed gfloat -[1.01,1.1] +[1,01,1,1] rw Zoom Speed Control the rate of zooming. -1.01 +1,01 @@ -17241,7 +17241,7 @@ GstGamma::gamma gdouble -[0.01,10] +[0,01,10] rw Gamma gamma. @@ -17365,7 +17365,7 @@ rw Ripple Amount of ripple (dB). -0.25 +0,25 @@ -17391,7 +17391,7 @@ GstAudioChebyshevFreqLimit::cutoff gfloat ->= 0 +[0,100000] rw Cutoff Cut off frequency (Hz). @@ -17421,11 +17421,11 @@ GstAudioChebyshevFreqLimit::ripple gfloat ->= 0 +[0,200] rw Ripple Amount of ripple (dB). -0.25 +0,25 diff --git a/gst/audiofx/audiochebband.c b/gst/audiofx/audiochebband.c index d473060..56ac8bd 100644 --- a/gst/audiofx/audiochebband.c +++ b/gst/audiofx/audiochebband.c @@ -53,6 +53,10 @@ * * As a special case, a Chebyshev type 1 filter with no ripple is a Butterworth filter. * + * + * Be warned that a too large number of poles can produce noise. The most poles are possible with + * a cutoff frequency at a quarter of the sampling rate. + * * Example launch line * * @@ -233,18 +237,24 @@ gst_audio_chebyshev_freq_band_class_init (GstAudioChebyshevFreqBandClass * g_param_spec_int ("type", "Type", "Type of the chebychev filter", 1, 2, 1, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + + /* FIXME: Don't use the complete possible range but restrict the upper boundary + * so automatically generated UIs can use a slider without */ g_object_class_install_property (gobject_class, PROP_LOWER_FREQUENCY, g_param_spec_float ("lower-frequency", "Lower frequency", - "Start frequency of the band (Hz)", 0.0, G_MAXFLOAT, + "Start frequency of the band (Hz)", 0.0, 100000.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); g_object_class_install_property (gobject_class, PROP_UPPER_FREQUENCY, g_param_spec_float ("upper-frequency", "Upper frequency", - "Stop frequency of the band (Hz)", 0.0, G_MAXFLOAT, + "Stop frequency of the band (Hz)", 0.0, 100000.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); g_object_class_install_property (gobject_class, PROP_RIPPLE, g_param_spec_float ("ripple", "Ripple", - "Amount of ripple (dB)", 0.0, G_MAXFLOAT, + "Amount of ripple (dB)", 0.0, 200.0, 0.25, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + /* FIXME: What to do about this upper boundary? With a frequencies near + * rate/4 32 poles are completely possible, with frequencies very low + * or very high 16 poles already produces only noise */ g_object_class_install_property (gobject_class, PROP_POLES, g_param_spec_int ("poles", "Poles", "Number of poles to use, will be rounded up to the next multiply of four", @@ -840,35 +850,26 @@ process (GstAudioChebyshevFreqBand * filter, return val; } -static void -process_64 (GstAudioChebyshevFreqBand * filter, - gdouble * data, guint num_samples) -{ - gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; - gdouble val; - - for (i = 0; i < num_samples / channels; i++) { - for (j = 0; j < channels; j++) { - val = process (filter, &filter->channels[j], *data); - *data++ = val; - } - } +#define DEFINE_PROCESS_FUNC(width,ctype) \ +static void \ +process_##width (GstAudioChebyshevFreqBand * filter, \ + g##ctype * data, guint num_samples) \ +{ \ + gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; \ + gdouble val; \ + \ + for (i = 0; i < num_samples / channels; i++) { \ + for (j = 0; j < channels; j++) { \ + val = process (filter, &filter->channels[j], *data); \ + *data++ = val; \ + } \ + } \ } -static void -process_32 (GstAudioChebyshevFreqBand * filter, - gfloat * data, guint num_samples) -{ - gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; - gdouble val; +DEFINE_PROCESS_FUNC (32, float); +DEFINE_PROCESS_FUNC (64, double); - for (i = 0; i < num_samples / channels; i++) { - for (j = 0; j < channels; j++) { - val = process (filter, &filter->channels[j], *data); - *data++ = val; - } - } -} +#undef DEFINE_PROCESS_FUNC /* GstBaseTransform vmethod implementations */ static GstFlowReturn diff --git a/gst/audiofx/audiocheblimit.c b/gst/audiofx/audiocheblimit.c index 872b277..ee9e5f3 100644 --- a/gst/audiofx/audiocheblimit.c +++ b/gst/audiofx/audiocheblimit.c @@ -49,6 +49,10 @@ * * As a special case, a Chebyshev type 1 filter with no ripple is a Butterworth filter. * + * + * Be warned that a too large number of poles can produce noise. The most poles are possible with + * a cutoff frequency at a quarter of the sampling rate. + * * Example launch line * * @@ -229,12 +233,19 @@ gst_audio_chebyshev_freq_limit_class_init (GstAudioChebyshevFreqLimitClass * g_object_class_install_property (gobject_class, PROP_TYPE, g_param_spec_int ("type", "Type", "Type of the chebychev filter", 1, 2, 1, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + + /* FIXME: Don't use the complete possible range but restrict the upper boundary + * so automatically generated UIs can use a slider without */ g_object_class_install_property (gobject_class, PROP_CUTOFF, g_param_spec_float ("cutoff", "Cutoff", "Cut off frequency (Hz)", 0.0, - G_MAXFLOAT, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + 100000.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); g_object_class_install_property (gobject_class, PROP_RIPPLE, g_param_spec_float ("ripple", "Ripple", "Amount of ripple (dB)", 0.0, - G_MAXFLOAT, 0.25, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + 200.0, 0.25, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + + /* FIXME: What to do about this upper boundary? With a cutoff frequency of + * rate/4 32 poles are completely possible, with a cutoff frequency very low + * or very high 16 poles already produces only noise */ g_object_class_install_property (gobject_class, PROP_POLES, g_param_spec_int ("poles", "Poles", "Number of poles to use, will be rounded up to the next even number", @@ -739,35 +750,26 @@ process (GstAudioChebyshevFreqLimit * filter, return val; } -static void -process_64 (GstAudioChebyshevFreqLimit * filter, - gdouble * data, guint num_samples) -{ - gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; - gdouble val; - - for (i = 0; i < num_samples / channels; i++) { - for (j = 0; j < channels; j++) { - val = process (filter, &filter->channels[j], *data); - *data++ = val; - } - } +#define DEFINE_PROCESS_FUNC(width,ctype) \ +static void \ +process_##width (GstAudioChebyshevFreqLimit * filter, \ + g##ctype * data, guint num_samples) \ +{ \ + gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; \ + gdouble val; \ + \ + for (i = 0; i < num_samples / channels; i++) { \ + for (j = 0; j < channels; j++) { \ + val = process (filter, &filter->channels[j], *data); \ + *data++ = val; \ + } \ + } \ } -static void -process_32 (GstAudioChebyshevFreqLimit * filter, - gfloat * data, guint num_samples) -{ - gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; - gdouble val; +DEFINE_PROCESS_FUNC (32, float); +DEFINE_PROCESS_FUNC (64, double); - for (i = 0; i < num_samples / channels; i++) { - for (j = 0; j < channels; j++) { - val = process (filter, &filter->channels[j], *data); - *data++ = val; - } - } -} +#undef DEFINE_PROCESS_FUNC /* GstBaseTransform vmethod implementations */ static GstFlowReturn diff --git a/gst/audiofx/audiochebyshevfreqband.c b/gst/audiofx/audiochebyshevfreqband.c index d473060..56ac8bd 100644 --- a/gst/audiofx/audiochebyshevfreqband.c +++ b/gst/audiofx/audiochebyshevfreqband.c @@ -53,6 +53,10 @@ * * As a special case, a Chebyshev type 1 filter with no ripple is a Butterworth filter. * + * + * Be warned that a too large number of poles can produce noise. The most poles are possible with + * a cutoff frequency at a quarter of the sampling rate. + * * Example launch line * * @@ -233,18 +237,24 @@ gst_audio_chebyshev_freq_band_class_init (GstAudioChebyshevFreqBandClass * g_param_spec_int ("type", "Type", "Type of the chebychev filter", 1, 2, 1, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + + /* FIXME: Don't use the complete possible range but restrict the upper boundary + * so automatically generated UIs can use a slider without */ g_object_class_install_property (gobject_class, PROP_LOWER_FREQUENCY, g_param_spec_float ("lower-frequency", "Lower frequency", - "Start frequency of the band (Hz)", 0.0, G_MAXFLOAT, + "Start frequency of the band (Hz)", 0.0, 100000.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); g_object_class_install_property (gobject_class, PROP_UPPER_FREQUENCY, g_param_spec_float ("upper-frequency", "Upper frequency", - "Stop frequency of the band (Hz)", 0.0, G_MAXFLOAT, + "Stop frequency of the band (Hz)", 0.0, 100000.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); g_object_class_install_property (gobject_class, PROP_RIPPLE, g_param_spec_float ("ripple", "Ripple", - "Amount of ripple (dB)", 0.0, G_MAXFLOAT, + "Amount of ripple (dB)", 0.0, 200.0, 0.25, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + /* FIXME: What to do about this upper boundary? With a frequencies near + * rate/4 32 poles are completely possible, with frequencies very low + * or very high 16 poles already produces only noise */ g_object_class_install_property (gobject_class, PROP_POLES, g_param_spec_int ("poles", "Poles", "Number of poles to use, will be rounded up to the next multiply of four", @@ -840,35 +850,26 @@ process (GstAudioChebyshevFreqBand * filter, return val; } -static void -process_64 (GstAudioChebyshevFreqBand * filter, - gdouble * data, guint num_samples) -{ - gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; - gdouble val; - - for (i = 0; i < num_samples / channels; i++) { - for (j = 0; j < channels; j++) { - val = process (filter, &filter->channels[j], *data); - *data++ = val; - } - } +#define DEFINE_PROCESS_FUNC(width,ctype) \ +static void \ +process_##width (GstAudioChebyshevFreqBand * filter, \ + g##ctype * data, guint num_samples) \ +{ \ + gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; \ + gdouble val; \ + \ + for (i = 0; i < num_samples / channels; i++) { \ + for (j = 0; j < channels; j++) { \ + val = process (filter, &filter->channels[j], *data); \ + *data++ = val; \ + } \ + } \ } -static void -process_32 (GstAudioChebyshevFreqBand * filter, - gfloat * data, guint num_samples) -{ - gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; - gdouble val; +DEFINE_PROCESS_FUNC (32, float); +DEFINE_PROCESS_FUNC (64, double); - for (i = 0; i < num_samples / channels; i++) { - for (j = 0; j < channels; j++) { - val = process (filter, &filter->channels[j], *data); - *data++ = val; - } - } -} +#undef DEFINE_PROCESS_FUNC /* GstBaseTransform vmethod implementations */ static GstFlowReturn diff --git a/gst/audiofx/audiochebyshevfreqlimit.c b/gst/audiofx/audiochebyshevfreqlimit.c index 872b277..ee9e5f3 100644 --- a/gst/audiofx/audiochebyshevfreqlimit.c +++ b/gst/audiofx/audiochebyshevfreqlimit.c @@ -49,6 +49,10 @@ * * As a special case, a Chebyshev type 1 filter with no ripple is a Butterworth filter. * + * + * Be warned that a too large number of poles can produce noise. The most poles are possible with + * a cutoff frequency at a quarter of the sampling rate. + * * Example launch line * * @@ -229,12 +233,19 @@ gst_audio_chebyshev_freq_limit_class_init (GstAudioChebyshevFreqLimitClass * g_object_class_install_property (gobject_class, PROP_TYPE, g_param_spec_int ("type", "Type", "Type of the chebychev filter", 1, 2, 1, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + + /* FIXME: Don't use the complete possible range but restrict the upper boundary + * so automatically generated UIs can use a slider without */ g_object_class_install_property (gobject_class, PROP_CUTOFF, g_param_spec_float ("cutoff", "Cutoff", "Cut off frequency (Hz)", 0.0, - G_MAXFLOAT, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + 100000.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); g_object_class_install_property (gobject_class, PROP_RIPPLE, g_param_spec_float ("ripple", "Ripple", "Amount of ripple (dB)", 0.0, - G_MAXFLOAT, 0.25, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + 200.0, 0.25, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + + /* FIXME: What to do about this upper boundary? With a cutoff frequency of + * rate/4 32 poles are completely possible, with a cutoff frequency very low + * or very high 16 poles already produces only noise */ g_object_class_install_property (gobject_class, PROP_POLES, g_param_spec_int ("poles", "Poles", "Number of poles to use, will be rounded up to the next even number", @@ -739,35 +750,26 @@ process (GstAudioChebyshevFreqLimit * filter, return val; } -static void -process_64 (GstAudioChebyshevFreqLimit * filter, - gdouble * data, guint num_samples) -{ - gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; - gdouble val; - - for (i = 0; i < num_samples / channels; i++) { - for (j = 0; j < channels; j++) { - val = process (filter, &filter->channels[j], *data); - *data++ = val; - } - } +#define DEFINE_PROCESS_FUNC(width,ctype) \ +static void \ +process_##width (GstAudioChebyshevFreqLimit * filter, \ + g##ctype * data, guint num_samples) \ +{ \ + gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; \ + gdouble val; \ + \ + for (i = 0; i < num_samples / channels; i++) { \ + for (j = 0; j < channels; j++) { \ + val = process (filter, &filter->channels[j], *data); \ + *data++ = val; \ + } \ + } \ } -static void -process_32 (GstAudioChebyshevFreqLimit * filter, - gfloat * data, guint num_samples) -{ - gint i, j, channels = GST_AUDIO_FILTER (filter)->format.channels; - gdouble val; +DEFINE_PROCESS_FUNC (32, float); +DEFINE_PROCESS_FUNC (64, double); - for (i = 0; i < num_samples / channels; i++) { - for (j = 0; j < channels; j++) { - val = process (filter, &filter->channels[j], *data); - *data++ = val; - } - } -} +#undef DEFINE_PROCESS_FUNC /* GstBaseTransform vmethod implementations */ static GstFlowReturn -- 2.7.4