GNOME Bugzilla – Bug 567577
[audiofx] Add generic IIR/FIR audio filter elements
Last modified: 2009-01-23 08:39:10 UTC
Hi, the attached patch adds generic IIR/FIR audio filter elements to the audiofx plugin, including documentation and unit tests. This will finally deprecate the filter plugin from gst-plugins-bad, which only contains a very limited IIR filter element.
Created attachment 126339 [details] [review] iir-fir-filters.diff
Looks good, some questions: 1) Would it be easy to add one sample of how to use the kiss-ftt to calculate the kernel? 2) in The doc-blob for 'element-audiofirfilter': 2a) what is the relation of the configured latency and the number of coefficients in the kernel (is there any). Or are there some guidelines for setting a good latency. I mean just setting this to 0 would most probably not work, but then nobody wants latency. 2b) just link the first occurance of FIR to the wikipedia article and drop the later link (same for iir). 3) GstAudioFIRFilter::rate-changed: Why is the signal needed. What about notify::caps for the src or sink pad? Also isn't the signal dangerous, what about a bus message.
(In reply to comment #2) > Looks good, some questions: > > 1) Would it be easy to add one sample of how to use the kiss-ftt to calculate > the kernel? No, that'll be easy. I'll also add a sample for every element on how to use it from C. > 2) in The doc-blob for 'element-audiofirfilter': > 2a) what is the relation of the configured latency and the number of > coefficients in the kernel (is there any). Or are there some guidelines for > setting a good latency. I mean just setting this to 0 would most probably not > work, but then nobody wants latency. The latency depends on the filter kernel. It could be from 0 to kernel_length-1. For example if you have a kernel [0, 0, 1] the latency introduced by the kernel would be 2 (the output of the filter would be the input of the filter shifted by two samples). > 2b) just link the first occurance of FIR to the wikipedia article and drop > the later link (same for iir). Good point :) > 3) GstAudioFIRFilter::rate-changed: Why is the signal needed. What about > notify::caps for the src or sink pad? Also isn't the signal dangerous, what > about a bus message. I used this signal instead of notify::caps because a user of the filter probably doesn't want to know about gstreamer internals like caps and only cares about the sampling rate. Also this could be improved a bit to be only emitted if the sampling rate changes (and not always when the caps are changing). A bus message won't work because you usually don't want to start processing buffers until the signal is completely handled (and a new filter kernel / coefficients are calculated and set for the new sampling rate).
Created attachment 126367 [details] [review] iir-fir-filters.diff
2009-01-13 Sebastian Dröge <sebastian.droege@collabora.co.uk> * configure.ac: * gst/audiofx/Makefile.am: * gst/audiofx/audiofirfilter.c: (gst_audio_fir_filter_base_init), (gst_audio_fir_filter_class_init), (gst_audio_fir_filter_update_kernel), (gst_audio_fir_filter_init), (gst_audio_fir_filter_setup), (gst_audio_fir_filter_finalize), (gst_audio_fir_filter_set_property), (gst_audio_fir_filter_get_property): * gst/audiofx/audiofirfilter.h: * gst/audiofx/audiofx.c: (plugin_init): * gst/audiofx/audioiirfilter.c: (gst_audio_iir_filter_base_init), (gst_audio_iir_filter_class_init), (gst_audio_iir_filter_update_coefficients), (gst_audio_iir_filter_init), (gst_audio_iir_filter_setup), (gst_audio_iir_filter_finalize), (gst_audio_iir_filter_set_property), (gst_audio_iir_filter_get_property): * gst/audiofx/audioiirfilter.h: Add audioiirfilter and audiofirfilter elements which allow generic IIR/FIR filters to be implemented by providing the filter coefficients. Fixes bug #567577. * docs/plugins/Makefile.am: * docs/plugins/gst-plugins-good-plugins-docs.sgml: * docs/plugins/gst-plugins-good-plugins-sections.txt: * docs/plugins/gst-plugins-good-plugins.args: * docs/plugins/gst-plugins-good-plugins.hierarchy: * docs/plugins/gst-plugins-good-plugins.signals: * docs/plugins/inspect/plugin-alaw.xml: * docs/plugins/inspect/plugin-audiofx.xml: * docs/plugins/inspect/plugin-avi.xml: * docs/plugins/inspect/plugin-flac.xml: * docs/plugins/inspect/plugin-mulaw.xml: * docs/plugins/inspect/plugin-video4linux2.xml: * docs/plugins/inspect/plugin-wavparse.xml: Add documentation for the audioiirfilter and audiofirfilter elements. * tests/check/Makefile.am: * tests/check/elements/audiofirfilter.c: (on_message), (on_rate_changed), (on_handoff), (GST_START_TEST), (audiofirfilter_suite): * tests/check/elements/audioiirfilter.c: (on_message), (on_rate_changed), (on_handoff), (GST_START_TEST), (audioiirfilter_suite): * tests/examples/Makefile.am: * tests/examples/audiofx/Makefile.am: * tests/examples/audiofx/firfilter-example.c: (on_message), (on_rate_changed), (main): * tests/examples/audiofx/iirfilter-example.c: (on_message), (on_rate_changed), (main): Add unit tests and example applications for the two filter elements.