From 99753365c6fe868196f454402f94e42d4e0170f0 Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Thu, 22 Jan 2009 10:40:34 +0100 Subject: Rename audioreverb to audioecho. Fixes bug #568395. The element can add an echo and a simple reverb effect to an audio stream but for a real reverb filter it would need some additional filtering to prevent a metallic-sounding result. --- docs/plugins/Makefile.am | 2 +- docs/plugins/gst-plugins-good-plugins-docs.sgml | 2 +- docs/plugins/gst-plugins-good-plugins-sections.txt | 26 +- docs/plugins/gst-plugins-good-plugins.args | 30 ++ docs/plugins/gst-plugins-good-plugins.hierarchy | 2 +- docs/plugins/inspect/plugin-audiofx.xml | 42 +-- docs/plugins/inspect/plugin-videocrop.xml | 4 +- gst/audiofx/Makefile.am | 4 +- gst/audiofx/audioecho.c | 367 +++++++++++++++++++++ gst/audiofx/audioecho.h | 68 ++++ gst/audiofx/audiofx.c | 6 +- gst/audiofx/audioreverb.c | 367 --------------------- gst/audiofx/audioreverb.h | 68 ---- tests/check/Makefile.am | 2 +- tests/check/elements/audioecho.c | 229 +++++++++++++ tests/check/elements/audioreverb.c | 229 ------------- 16 files changed, 739 insertions(+), 709 deletions(-) create mode 100644 gst/audiofx/audioecho.c create mode 100644 gst/audiofx/audioecho.h delete mode 100644 gst/audiofx/audioreverb.c delete mode 100644 gst/audiofx/audioreverb.h create mode 100644 tests/check/elements/audioecho.c delete mode 100644 tests/check/elements/audioreverb.c diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am index 1c03636b..f5f0d97f 100644 --- a/docs/plugins/Makefile.am +++ b/docs/plugins/Makefile.am @@ -106,7 +106,7 @@ EXTRA_HFILES = \ $(top_srcdir)/gst/alpha/gstalphacolor.h \ $(top_srcdir)/gst/apetag/gstapedemux.h \ $(top_srcdir)/gst/audiofx/audioamplify.h \ - $(top_srcdir)/gst/audiofx/audioreverb.h \ + $(top_srcdir)/gst/audiofx/audioecho.h \ $(top_srcdir)/gst/audiofx/audiodynamic.h \ $(top_srcdir)/gst/audiofx/audioinvert.h \ $(top_srcdir)/gst/audiofx/audiokaraoke.h \ diff --git a/docs/plugins/gst-plugins-good-plugins-docs.sgml b/docs/plugins/gst-plugins-good-plugins-docs.sgml index 231017d7..1a9c2ea0 100644 --- a/docs/plugins/gst-plugins-good-plugins-docs.sgml +++ b/docs/plugins/gst-plugins-good-plugins-docs.sgml @@ -23,7 +23,7 @@ - + diff --git a/docs/plugins/gst-plugins-good-plugins-sections.txt b/docs/plugins/gst-plugins-good-plugins-sections.txt index 03790c5b..332c36d4 100644 --- a/docs/plugins/gst-plugins-good-plugins-sections.txt +++ b/docs/plugins/gst-plugins-good-plugins-sections.txt @@ -117,19 +117,19 @@ gst_audio_iir_filter_get_type
-element-audioreverb -audioreverb -GstAudioReverb - -GstAudioReverbClass -GstAudioReverbProcessFunc -GST_AUDIO_REVERB -GST_AUDIO_REVERB_CLASS -GST_AUDIO_REVERB_GET_CLASS -GST_IS_AUDIO_REVERB -GST_IS_AUDIO_REVERB_CLASS -GST_TYPE_AUDIO_REVERB -gst_audio_reverb_get_type +element-audioecho +audioecho +GstAudioEcho + +GstAudioEchoClass +GstAudioEchoProcessFunc +GST_AUDIO_ECHO +GST_AUDIO_ECHO_CLASS +GST_AUDIO_ECHO_GET_CLASS +GST_IS_AUDIO_ECHO +GST_IS_AUDIO_ECHO_CLASS +GST_TYPE_AUDIO_ECHO +gst_audio_echo_get_type
diff --git a/docs/plugins/gst-plugins-good-plugins.args b/docs/plugins/gst-plugins-good-plugins.args index 7a2603d5..5d646289 100644 --- a/docs/plugins/gst-plugins-good-plugins.args +++ b/docs/plugins/gst-plugins-good-plugins.args @@ -19768,3 +19768,33 @@ 0 + +GstAudioEcho::delay +guint64 +>= 1 +rw +Delay +Delay of the echo in nanosecondsecho. +1 + + + +GstAudioEcho::feedback +gfloat +[0,1] +rw +Feedback +Amount of feedback. +0 + + + +GstAudioEcho::intensity +gfloat +[0,1] +rw +Intensity +Intensity of the echo. +0 + + diff --git a/docs/plugins/gst-plugins-good-plugins.hierarchy b/docs/plugins/gst-plugins-good-plugins.hierarchy index e02a501e..914c4d84 100644 --- a/docs/plugins/gst-plugins-good-plugins.hierarchy +++ b/docs/plugins/gst-plugins-good-plugins.hierarchy @@ -64,7 +64,7 @@ GObject GstAudioWSincLimit GstAudioWSincBand GstAudioFIRFilter - GstAudioReverb + GstAudioEcho GstIirEqualizer GstIirEqualizerNBands GstIirEqualizer3Bands diff --git a/docs/plugins/inspect/plugin-audiofx.xml b/docs/plugins/inspect/plugin-audiofx.xml index 171d8b43..d06c3ab5 100644 --- a/docs/plugins/inspect/plugin-audiofx.xml +++ b/docs/plugins/inspect/plugin-audiofx.xml @@ -93,6 +93,27 @@ + + audioecho + Audio echo + Filter/Effect/Audio + Adds an echo or reverb effect to an audio stream + Sebastian Dröge <sebastian.droege@collabora.co.uk> + + + sink + sink + always +
audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]
+
+ + src + source + always +
audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]
+
+
+
audiofirfilter Audio FIR filter @@ -198,27 +219,6 @@ - - audioreverb - Audio reverb - Filter/Effect/Audio - Adds an echo or reverb effect to an audio stream - Sebastian Dröge <sebastian.droege@collabora.co.uk> - - - sink - sink - always -
audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]
-
- - src - source - always -
audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]
-
-
-
audiowsincband Band pass & band reject filter diff --git a/docs/plugins/inspect/plugin-videocrop.xml b/docs/plugins/inspect/plugin-videocrop.xml index e197c99d..f1ebfe25 100644 --- a/docs/plugins/inspect/plugin-videocrop.xml +++ b/docs/plugins/inspect/plugin-videocrop.xml @@ -20,13 +20,13 @@ src source always -
video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, alpha_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, alpha_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, alpha_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, alpha_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)AYUV, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YVYU, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)UYVY, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)Y800, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)I420, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YV12, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)16, depth=(int)16, endianness=(int)1234, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)16, depth=(int)15, endianness=(int)1234, red_mask=(int)31744, green_mask=(int)992, blue_mask=(int)31, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
+
video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, alpha_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, alpha_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, alpha_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, alpha_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)AYUV, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YVYU, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)UYVY, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)Y800, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)I420, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YV12, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)16, depth=(int)16, endianness=(int)1234, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)16, depth=(int)15, endianness=(int)1234, red_mask=(int)31744, green_mask=(int)992, blue_mask=(int)31, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-gray, bpp=(int)8, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
sink sink always -
video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, alpha_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, alpha_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, alpha_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, alpha_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)AYUV, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YVYU, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)UYVY, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)Y800, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)I420, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YV12, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)16, depth=(int)16, endianness=(int)1234, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)16, depth=(int)15, endianness=(int)1234, red_mask=(int)31744, green_mask=(int)992, blue_mask=(int)31, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
+
video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)-16777216, green_mask=(int)16711680, blue_mask=(int)65280, alpha_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, alpha_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, alpha_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)32, depth=(int)32, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, alpha_mask=(int)-16777216, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)24, depth=(int)24, endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, blue_mask=(int)16711680, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)AYUV, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YVYU, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)UYVY, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)Y800, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)I420, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-yuv, format=(fourcc)YV12, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)16, depth=(int)16, endianness=(int)1234, red_mask=(int)63488, green_mask=(int)2016, blue_mask=(int)31, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-rgb, bpp=(int)16, depth=(int)15, endianness=(int)1234, red_mask=(int)31744, green_mask=(int)992, blue_mask=(int)31, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]; video/x-raw-gray, bpp=(int)8, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]
diff --git a/gst/audiofx/Makefile.am b/gst/audiofx/Makefile.am index f4f02be2..22f5fd02 100644 --- a/gst/audiofx/Makefile.am +++ b/gst/audiofx/Makefile.am @@ -17,7 +17,7 @@ libgstaudiofx_la_SOURCES = audiofx.c\ audiowsincband.c \ audiowsinclimit.c \ audiofirfilter.c \ - audioreverb.c + audioecho.c # flags used to compile this plugin libgstaudiofx_la_CFLAGS = $(GST_CFLAGS) \ @@ -47,6 +47,6 @@ noinst_HEADERS = audiopanorama.h \ audiowsincband.h \ audiowsinclimit.h \ audiofirfilter.h \ - audioreverb.h \ + audioecho.h \ math_compat.h diff --git a/gst/audiofx/audioecho.c b/gst/audiofx/audioecho.c new file mode 100644 index 00000000..04d51240 --- /dev/null +++ b/gst/audiofx/audioecho.c @@ -0,0 +1,367 @@ +/* + * GStreamer + * Copyright (C) 2009 Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/** + * SECTION:element-audioecho + * + * + * audioecho adds an echo or reverb effect to an audio stream. The echo + * delay, intensity and the percentage of feedback can be configured. + * + * + * gst-launch filesrc location="melo1.ogg" ! audioconvert ! audioecho delay=500000000 intensity=0.6 feedback=0.4 ! audioconvert ! autoaudiosink + * gst-launch filesrc location="melo1.ogg" ! decodebin ! audioconvert ! audioecho delay=50000000 intensity=0.6 feedback=0.4 ! audioconvert ! autoaudiosink + * + * + * + * + * Since: 0.10.12 + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#include "audioecho.h" + +#define GST_CAT_DEFAULT gst_audio_echo_debug +GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); + +enum +{ + PROP_0, + PROP_DELAY, + PROP_INTENSITY, + PROP_FEEDBACK +}; + +#define ALLOWED_CAPS \ + "audio/x-raw-float," \ + " width=(int) { 32, 64 }, " \ + " endianness=(int)BYTE_ORDER," \ + " rate=(int)[1,MAX]," \ + " channels=(int)[1,MAX]" + +#define DEBUG_INIT(bla) \ + GST_DEBUG_CATEGORY_INIT (gst_audio_echo_debug, "audioecho", 0, "audioecho element"); + +GST_BOILERPLATE_FULL (GstAudioEcho, gst_audio_echo, GstAudioFilter, + GST_TYPE_AUDIO_FILTER, DEBUG_INIT); + +static void gst_audio_echo_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_audio_echo_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static void gst_audio_echo_finalize (GObject * object); + +static gboolean gst_audio_echo_setup (GstAudioFilter * self, + GstRingBufferSpec * format); +static gboolean gst_audio_echo_stop (GstBaseTransform * base); +static GstFlowReturn gst_audio_echo_transform_ip (GstBaseTransform * base, + GstBuffer * buf); + +static void gst_audio_echo_transform_float (GstAudioEcho * self, + gfloat * data, guint num_samples); +static void gst_audio_echo_transform_double (GstAudioEcho * self, + gdouble * data, guint num_samples); + +/* GObject vmethod implementations */ + +static void +gst_audio_echo_base_init (gpointer klass) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + GstCaps *caps; + + gst_element_class_set_details_simple (element_class, "Audio echo", + "Filter/Effect/Audio", + "Adds an echo or reverb effect to an audio stream", + "Sebastian Dröge "); + + caps = gst_caps_from_string (ALLOWED_CAPS); + gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass), + caps); + gst_caps_unref (caps); +} + +static void +gst_audio_echo_class_init (GstAudioEchoClass * klass) +{ + GObjectClass *gobject_class = (GObjectClass *) klass; + GstBaseTransformClass *basetransform_class = (GstBaseTransformClass *) klass; + GstAudioFilterClass *audioself_class = (GstAudioFilterClass *) klass; + + gobject_class->set_property = gst_audio_echo_set_property; + gobject_class->get_property = gst_audio_echo_get_property; + gobject_class->finalize = gst_audio_echo_finalize; + + g_object_class_install_property (gobject_class, PROP_DELAY, + g_param_spec_uint64 ("delay", "Delay", + "Delay of the echo in nanosecondsecho", 1, G_MAXUINT64, + 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS + | GST_PARAM_CONTROLLABLE)); + + g_object_class_install_property (gobject_class, PROP_INTENSITY, + g_param_spec_float ("intensity", "Intensity", + "Intensity of the echo", 0.0, 1.0, + 0.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS + | GST_PARAM_CONTROLLABLE)); + + g_object_class_install_property (gobject_class, PROP_FEEDBACK, + g_param_spec_float ("feedback", "Feedback", + "Amount of feedback", 0.0, 1.0, + 0.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS + | GST_PARAM_CONTROLLABLE)); + + audioself_class->setup = GST_DEBUG_FUNCPTR (gst_audio_echo_setup); + basetransform_class->transform_ip = + GST_DEBUG_FUNCPTR (gst_audio_echo_transform_ip); + basetransform_class->stop = GST_DEBUG_FUNCPTR (gst_audio_echo_stop); +} + +static void +gst_audio_echo_init (GstAudioEcho * self, GstAudioEchoClass * klass) +{ + self->delay = 1; + self->intensity = 0.0; + self->feedback = 0.0; + + gst_base_transform_set_in_place (GST_BASE_TRANSFORM (self), TRUE); +} + +static void +gst_audio_echo_finalize (GObject * object) +{ + GstAudioEcho *self = GST_AUDIO_ECHO (object); + + g_free (self->buffer); + self->buffer = NULL; + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +gst_audio_echo_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstAudioEcho *self = GST_AUDIO_ECHO (object); + + switch (prop_id) { + case PROP_DELAY:{ + guint rate, width, channels; + + GST_BASE_TRANSFORM_LOCK (self); + self->delay = g_value_get_uint64 (value); + + rate = GST_AUDIO_FILTER (self)->format.rate; + width = GST_AUDIO_FILTER (self)->format.width / 8; + channels = GST_AUDIO_FILTER (self)->format.channels; + + if (self->buffer && rate > 0) { + guint new_echo = + MAX (gst_util_uint64_scale (self->delay, rate, GST_SECOND), 1); + guint new_size = new_echo * width * channels; + + if (new_size > self->buffer_size) { + guint i; + guint8 *old_buffer = self->buffer; + + self->buffer_size = new_size; + self->buffer = g_malloc0 (new_size); + + for (i = 0; i < self->buffer_size_frames; i++) { + memcpy (&self->buffer[i * width * channels], + &old_buffer[((i + + self->buffer_pos) % self->buffer_size_frames) * + width * channels], channels * width); + } + self->buffer_size_frames = self->delay_frames = new_echo; + self->buffer_pos = 0; + } + } else if (self->buffer) { + g_free (self->buffer); + self->buffer = NULL; + } + + GST_BASE_TRANSFORM_UNLOCK (self); + } + break; + case PROP_INTENSITY:{ + GST_BASE_TRANSFORM_LOCK (self); + self->intensity = g_value_get_float (value); + GST_BASE_TRANSFORM_UNLOCK (self); + } + break; + case PROP_FEEDBACK:{ + GST_BASE_TRANSFORM_LOCK (self); + self->feedback = g_value_get_float (value); + GST_BASE_TRANSFORM_UNLOCK (self); + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_audio_echo_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstAudioEcho *self = GST_AUDIO_ECHO (object); + + switch (prop_id) { + case PROP_DELAY: + GST_BASE_TRANSFORM_LOCK (self); + g_value_set_uint64 (value, self->delay); + GST_BASE_TRANSFORM_UNLOCK (self); + break; + case PROP_INTENSITY: + GST_BASE_TRANSFORM_LOCK (self); + g_value_set_float (value, self->intensity); + GST_BASE_TRANSFORM_UNLOCK (self); + break; + case PROP_FEEDBACK: + GST_BASE_TRANSFORM_LOCK (self); + g_value_set_float (value, self->feedback); + GST_BASE_TRANSFORM_UNLOCK (self); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/* GstAudioFilter vmethod implementations */ + +static gboolean +gst_audio_echo_setup (GstAudioFilter * base, GstRingBufferSpec * format) +{ + GstAudioEcho *self = GST_AUDIO_ECHO (base); + gboolean ret = TRUE; + + if (format->type == GST_BUFTYPE_FLOAT && format->width == 32) + self->process = (GstAudioEchoProcessFunc) + gst_audio_echo_transform_float; + else if (format->type == GST_BUFTYPE_FLOAT && format->width == 64) + self->process = (GstAudioEchoProcessFunc) + gst_audio_echo_transform_double; + else + ret = FALSE; + + g_free (self->buffer); + self->buffer = NULL; + self->buffer_pos = 0; + self->buffer_size = 0; + self->buffer_size_frames = 0; + + return ret; +} + +static gboolean +gst_audio_echo_stop (GstBaseTransform * base) +{ + GstAudioEcho *self = GST_AUDIO_ECHO (base); + + g_free (self->buffer); + self->buffer = NULL; + self->buffer_pos = 0; + self->buffer_size = 0; + self->buffer_size_frames = 0; + + return TRUE; +} + +#define TRANSFORM_FUNC(name, type) \ +static void \ +gst_audio_echo_transform_##name (GstAudioEcho * self, \ + type * data, guint num_samples) \ +{ \ + type *buffer = (type *) self->buffer; \ + guint channels = GST_AUDIO_FILTER (self)->format.channels; \ + guint rate = GST_AUDIO_FILTER (self)->format.rate; \ + guint i, j; \ + guint echo_index = self->buffer_size_frames - self->delay_frames; \ + gdouble echo_off = ((((gdouble) self->delay) * rate) / GST_SECOND) - self->delay_frames; \ + \ + if (echo_off < 0.0) \ + echo_off = 0.0; \ + \ + num_samples /= channels; \ + \ + for (i = 0; i < num_samples; i++) { \ + guint echo0_index = ((echo_index + self->buffer_pos) % self->buffer_size_frames) * channels; \ + guint echo1_index = ((echo_index + self->buffer_pos +1) % self->buffer_size_frames) * channels; \ + guint rbout_index = (self->buffer_pos % self->buffer_size_frames) * channels; \ + for (j = 0; j < channels; j++) { \ + gdouble in = data[i*channels + j]; \ + gdouble echo0 = buffer[echo0_index + j]; \ + gdouble echo1 = buffer[echo1_index + j]; \ + gdouble echo = echo0 + (echo1-echo0)*echo_off; \ + type out = in + self->intensity * echo; \ + \ + data[i*channels + j] = out; \ + \ + buffer[rbout_index + j] = in + self->feedback * echo; \ + } \ + self->buffer_pos = (self->buffer_pos + 1) % self->buffer_size_frames; \ + } \ +} + +TRANSFORM_FUNC (float, gfloat); +TRANSFORM_FUNC (double, gdouble); + +/* GstBaseTransform vmethod implementations */ +static GstFlowReturn +gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf) +{ + GstAudioEcho *self = GST_AUDIO_ECHO (base); + guint num_samples = + GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (self)->format.width / 8); + + if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buf))) + gst_object_sync_values (G_OBJECT (self), GST_BUFFER_TIMESTAMP (buf)); + + if (self->buffer == NULL) { + guint width, rate, channels; + + width = GST_AUDIO_FILTER (self)->format.width / 8; + rate = GST_AUDIO_FILTER (self)->format.rate; + channels = GST_AUDIO_FILTER (self)->format.channels; + + self->delay_frames = + MAX (gst_util_uint64_scale (self->delay, rate, GST_SECOND), 1); + + self->buffer_size_frames = MAX (self->delay_frames, 1000); + self->buffer_size = self->buffer_size_frames * width * channels; + self->buffer = g_malloc0 (self->buffer_size); + self->buffer_pos = 0; + } + + self->process (self, GST_BUFFER_DATA (buf), num_samples); + + return GST_FLOW_OK; +} diff --git a/gst/audiofx/audioecho.h b/gst/audiofx/audioecho.h new file mode 100644 index 00000000..9513bb8e --- /dev/null +++ b/gst/audiofx/audioecho.h @@ -0,0 +1,68 @@ +/* + * GStreamer + * Copyright (C) 2009 Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_AUDIO_ECHO_H__ +#define __GST_AUDIO_ECHO_H__ + +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define GST_TYPE_AUDIO_ECHO (gst_audio_echo_get_type()) +#define GST_AUDIO_ECHO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_ECHO,GstAudioEcho)) +#define GST_IS_AUDIO_ECHO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_ECHO)) +#define GST_AUDIO_ECHO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_AUDIO_ECHO,GstAudioEchoClass)) +#define GST_IS_AUDIO_ECHO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_AUDIO_ECHO)) +#define GST_AUDIO_ECHO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_AUDIO_ECHO,GstAudioEchoClass)) +typedef struct _GstAudioEcho GstAudioEcho; +typedef struct _GstAudioEchoClass GstAudioEchoClass; + +typedef void (*GstAudioEchoProcessFunc) (GstAudioEcho *, guint8 *, guint); + +struct _GstAudioEcho +{ + GstAudioFilter audiofilter; + + guint64 delay; + gfloat intensity; + gfloat feedback; + + /* < private > */ + GstAudioEchoProcessFunc process; + guint delay_frames; + guint8 *buffer; + guint buffer_pos; + guint buffer_size; + guint buffer_size_frames; +}; + +struct _GstAudioEchoClass +{ + GstAudioFilterClass parent; +}; + +GType gst_audio_echo_get_type (void); + +G_END_DECLS + +#endif /* __GST_AUDIO_ECHO_H__ */ diff --git a/gst/audiofx/audiofx.c b/gst/audiofx/audiofx.c index e23a638f..a268724d 100644 --- a/gst/audiofx/audiofx.c +++ b/gst/audiofx/audiofx.c @@ -36,7 +36,7 @@ #include "audiowsincband.h" #include "audiowsinclimit.h" #include "audiofirfilter.h" -#include "audioreverb.h" +#include "audioecho.h" /* entry point to initialize the plug-in * initialize the plug-in itself @@ -71,8 +71,8 @@ plugin_init (GstPlugin * plugin) GST_TYPE_AUDIO_WSINC_BAND) && gst_element_register (plugin, "audiofirfilter", GST_RANK_NONE, GST_TYPE_AUDIO_FIR_FILTER) && - gst_element_register (plugin, "audioreverb", GST_RANK_NONE, - GST_TYPE_AUDIO_REVERB)); + gst_element_register (plugin, "audioecho", GST_RANK_NONE, + GST_TYPE_AUDIO_ECHO)); } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/gst/audiofx/audioreverb.c b/gst/audiofx/audioreverb.c deleted file mode 100644 index 2d661b16..00000000 --- a/gst/audiofx/audioreverb.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Sebastian Dröge - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/** - * SECTION:element-audioreverb - * - * - * audioreverb adds an echo or revert effect to an audio stream. The echo - * reverb, intensity and the percentage of feedback can be configured. - * - * - * gst-launch filesrc location="melo1.ogg" ! audioconvert ! audioreverb reverb=500000000 intensity=0.6 feedback=0.4 ! audioconvert ! autoaudiosink - * gst-launch filesrc location="melo1.ogg" ! decodebin ! audioconvert ! audioreverb reverb=50000000 intensity=0.6 feedback=0.4 ! audioconvert ! autoaudiosink - * - * - * - * - * Since: 0.10.12 - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include - -#include "audioreverb.h" - -#define GST_CAT_DEFAULT gst_audio_reverb_debug -GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); - -enum -{ - PROP_0, - PROP_DELAY, - PROP_INTENSITY, - PROP_FEEDBACK -}; - -#define ALLOWED_CAPS \ - "audio/x-raw-float," \ - " width=(int) { 32, 64 }, " \ - " endianness=(int)BYTE_ORDER," \ - " rate=(int)[1,MAX]," \ - " channels=(int)[1,MAX]" - -#define DEBUG_INIT(bla) \ - GST_DEBUG_CATEGORY_INIT (gst_audio_reverb_debug, "audioreverb", 0, "audioreverb element"); - -GST_BOILERPLATE_FULL (GstAudioReverb, gst_audio_reverb, GstAudioFilter, - GST_TYPE_AUDIO_FILTER, DEBUG_INIT); - -static void gst_audio_reverb_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec); -static void gst_audio_reverb_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec); -static void gst_audio_reverb_finalize (GObject * object); - -static gboolean gst_audio_reverb_setup (GstAudioFilter * self, - GstRingBufferSpec * format); -static gboolean gst_audio_reverb_stop (GstBaseTransform * base); -static GstFlowReturn gst_audio_reverb_transform_ip (GstBaseTransform * base, - GstBuffer * buf); - -static void gst_audio_reverb_transform_float (GstAudioReverb * self, - gfloat * data, guint num_samples); -static void gst_audio_reverb_transform_double (GstAudioReverb * self, - gdouble * data, guint num_samples); - -/* GObject vmethod implementations */ - -static void -gst_audio_reverb_base_init (gpointer klass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - GstCaps *caps; - - gst_element_class_set_details_simple (element_class, "Audio reverb", - "Filter/Effect/Audio", - "Adds an echo or reverb effect to an audio stream", - "Sebastian Dröge "); - - caps = gst_caps_from_string (ALLOWED_CAPS); - gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (klass), - caps); - gst_caps_unref (caps); -} - -static void -gst_audio_reverb_class_init (GstAudioReverbClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - GstBaseTransformClass *basetransform_class = (GstBaseTransformClass *) klass; - GstAudioFilterClass *audioself_class = (GstAudioFilterClass *) klass; - - gobject_class->set_property = gst_audio_reverb_set_property; - gobject_class->get_property = gst_audio_reverb_get_property; - gobject_class->finalize = gst_audio_reverb_finalize; - - g_object_class_install_property (gobject_class, PROP_DELAY, - g_param_spec_uint64 ("delay", "Delay", - "Delay of the echo in nanoseconds", 1, G_MAXUINT64, - 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS - | GST_PARAM_CONTROLLABLE)); - - g_object_class_install_property (gobject_class, PROP_INTENSITY, - g_param_spec_float ("intensity", "Intensity", - "Intensity of the echo", 0.0, 1.0, - 0.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS - | GST_PARAM_CONTROLLABLE)); - - g_object_class_install_property (gobject_class, PROP_FEEDBACK, - g_param_spec_float ("feedback", "Feedback", - "Amount of feedback", 0.0, 1.0, - 0.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS - | GST_PARAM_CONTROLLABLE)); - - audioself_class->setup = GST_DEBUG_FUNCPTR (gst_audio_reverb_setup); - basetransform_class->transform_ip = - GST_DEBUG_FUNCPTR (gst_audio_reverb_transform_ip); - basetransform_class->stop = GST_DEBUG_FUNCPTR (gst_audio_reverb_stop); -} - -static void -gst_audio_reverb_init (GstAudioReverb * self, GstAudioReverbClass * klass) -{ - self->delay = 1; - self->intensity = 0.0; - self->feedback = 0.0; - - gst_base_transform_set_in_place (GST_BASE_TRANSFORM (self), TRUE); -} - -static void -gst_audio_reverb_finalize (GObject * object) -{ - GstAudioReverb *self = GST_AUDIO_REVERB (object); - - g_free (self->buffer); - self->buffer = NULL; - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gst_audio_reverb_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstAudioReverb *self = GST_AUDIO_REVERB (object); - - switch (prop_id) { - case PROP_DELAY:{ - guint rate, width, channels; - - GST_BASE_TRANSFORM_LOCK (self); - self->delay = g_value_get_uint64 (value); - - rate = GST_AUDIO_FILTER (self)->format.rate; - width = GST_AUDIO_FILTER (self)->format.width / 8; - channels = GST_AUDIO_FILTER (self)->format.channels; - - if (self->buffer && rate > 0) { - guint new_reverb = - MAX (gst_util_uint64_scale (self->delay, rate, GST_SECOND), 1); - guint new_size = new_reverb * width * channels; - - if (new_size > self->buffer_size) { - guint i; - guint8 *old_buffer = self->buffer; - - self->buffer_size = new_size; - self->buffer = g_malloc0 (new_size); - - for (i = 0; i < self->buffer_size_frames; i++) { - memcpy (&self->buffer[i * width * channels], - &old_buffer[((i + - self->buffer_pos) % self->buffer_size_frames) * - width * channels], channels * width); - } - self->buffer_size_frames = self->delay_frames = new_reverb; - self->buffer_pos = 0; - } - } else if (self->buffer) { - g_free (self->buffer); - self->buffer = NULL; - } - - GST_BASE_TRANSFORM_UNLOCK (self); - } - break; - case PROP_INTENSITY:{ - GST_BASE_TRANSFORM_LOCK (self); - self->intensity = g_value_get_float (value); - GST_BASE_TRANSFORM_UNLOCK (self); - } - break; - case PROP_FEEDBACK:{ - GST_BASE_TRANSFORM_LOCK (self); - self->feedback = g_value_get_float (value); - GST_BASE_TRANSFORM_UNLOCK (self); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_audio_reverb_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - GstAudioReverb *self = GST_AUDIO_REVERB (object); - - switch (prop_id) { - case PROP_DELAY: - GST_BASE_TRANSFORM_LOCK (self); - g_value_set_uint64 (value, self->delay); - GST_BASE_TRANSFORM_UNLOCK (self); - break; - case PROP_INTENSITY: - GST_BASE_TRANSFORM_LOCK (self); - g_value_set_float (value, self->intensity); - GST_BASE_TRANSFORM_UNLOCK (self); - break; - case PROP_FEEDBACK: - GST_BASE_TRANSFORM_LOCK (self); - g_value_set_float (value, self->feedback); - GST_BASE_TRANSFORM_UNLOCK (self); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/* GstAudioFilter vmethod implementations */ - -static gboolean -gst_audio_reverb_setup (GstAudioFilter * base, GstRingBufferSpec * format) -{ - GstAudioReverb *self = GST_AUDIO_REVERB (base); - gboolean ret = TRUE; - - if (format->type == GST_BUFTYPE_FLOAT && format->width == 32) - self->process = (GstAudioReverbProcessFunc) - gst_audio_reverb_transform_float; - else if (format->type == GST_BUFTYPE_FLOAT && format->width == 64) - self->process = (GstAudioReverbProcessFunc) - gst_audio_reverb_transform_double; - else - ret = FALSE; - - g_free (self->buffer); - self->buffer = NULL; - self->buffer_pos = 0; - self->buffer_size = 0; - self->buffer_size_frames = 0; - - return ret; -} - -static gboolean -gst_audio_reverb_stop (GstBaseTransform * base) -{ - GstAudioReverb *self = GST_AUDIO_REVERB (base); - - g_free (self->buffer); - self->buffer = NULL; - self->buffer_pos = 0; - self->buffer_size = 0; - self->buffer_size_frames = 0; - - return TRUE; -} - -#define TRANSFORM_FUNC(name, type) \ -static void \ -gst_audio_reverb_transform_##name (GstAudioReverb * self, \ - type * data, guint num_samples) \ -{ \ - type *buffer = (type *) self->buffer; \ - guint channels = GST_AUDIO_FILTER (self)->format.channels; \ - guint rate = GST_AUDIO_FILTER (self)->format.rate; \ - guint i, j; \ - guint reverb_index = self->buffer_size_frames - self->delay_frames; \ - gdouble reverb_off = ((((gdouble) self->delay) * rate) / GST_SECOND) - self->delay_frames; \ - \ - if (reverb_off < 0.0) \ - reverb_off = 0.0; \ - \ - num_samples /= channels; \ - \ - for (i = 0; i < num_samples; i++) { \ - guint echo0_index = ((reverb_index + self->buffer_pos) % self->buffer_size_frames) * channels; \ - guint echo1_index = ((reverb_index + self->buffer_pos +1) % self->buffer_size_frames) * channels; \ - guint rbout_index = (self->buffer_pos % self->buffer_size_frames) * channels; \ - for (j = 0; j < channels; j++) { \ - gdouble in = data[i*channels + j]; \ - gdouble echo0 = buffer[echo0_index + j]; \ - gdouble echo1 = buffer[echo1_index + j]; \ - gdouble echo = echo0 + (echo1-echo0)*reverb_off; \ - type out = in + self->intensity * echo; \ - \ - data[i*channels + j] = out; \ - \ - buffer[rbout_index + j] = in + self->feedback * echo; \ - } \ - self->buffer_pos = (self->buffer_pos + 1) % self->buffer_size_frames; \ - } \ -} - -TRANSFORM_FUNC (float, gfloat); -TRANSFORM_FUNC (double, gdouble); - -/* GstBaseTransform vmethod implementations */ -static GstFlowReturn -gst_audio_reverb_transform_ip (GstBaseTransform * base, GstBuffer * buf) -{ - GstAudioReverb *self = GST_AUDIO_REVERB (base); - guint num_samples = - GST_BUFFER_SIZE (buf) / (GST_AUDIO_FILTER (self)->format.width / 8); - - if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buf))) - gst_object_sync_values (G_OBJECT (self), GST_BUFFER_TIMESTAMP (buf)); - - if (self->buffer == NULL) { - guint width, rate, channels; - - width = GST_AUDIO_FILTER (self)->format.width / 8; - rate = GST_AUDIO_FILTER (self)->format.rate; - channels = GST_AUDIO_FILTER (self)->format.channels; - - self->delay_frames = - MAX (gst_util_uint64_scale (self->delay, rate, GST_SECOND), 1); - - self->buffer_size_frames = MAX (self->delay_frames, 1000); - self->buffer_size = self->buffer_size_frames * width * channels; - self->buffer = g_malloc0 (self->buffer_size); - self->buffer_pos = 0; - } - - self->process (self, GST_BUFFER_DATA (buf), num_samples); - - return GST_FLOW_OK; -} diff --git a/gst/audiofx/audioreverb.h b/gst/audiofx/audioreverb.h deleted file mode 100644 index 3ef5682e..00000000 --- a/gst/audiofx/audioreverb.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2009 Sebastian Dröge - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GST_AUDIO_REVERB_H__ -#define __GST_AUDIO_REVERB_H__ - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define GST_TYPE_AUDIO_REVERB (gst_audio_reverb_get_type()) -#define GST_AUDIO_REVERB(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_REVERB,GstAudioReverb)) -#define GST_IS_AUDIO_REVERB(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_REVERB)) -#define GST_AUDIO_REVERB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_AUDIO_REVERB,GstAudioReverbClass)) -#define GST_IS_AUDIO_REVERB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_AUDIO_REVERB)) -#define GST_AUDIO_REVERB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_AUDIO_REVERB,GstAudioReverbClass)) -typedef struct _GstAudioReverb GstAudioReverb; -typedef struct _GstAudioReverbClass GstAudioReverbClass; - -typedef void (*GstAudioReverbProcessFunc) (GstAudioReverb *, guint8 *, guint); - -struct _GstAudioReverb -{ - GstAudioFilter audiofilter; - - guint64 delay; - gfloat intensity; - gfloat feedback; - - /* < private > */ - GstAudioReverbProcessFunc process; - guint delay_frames; - guint8 *buffer; - guint buffer_pos; - guint buffer_size; - guint buffer_size_frames; -}; - -struct _GstAudioReverbClass -{ - GstAudioFilterClass parent; -}; - -GType gst_audio_reverb_get_type (void); - -G_END_DECLS - -#endif /* __GST_AUDIO_REVERB_H__ */ diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index ee0afdc9..89a151c4 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -74,7 +74,7 @@ check_PROGRAMS = \ elements/audiocheblimit \ elements/audioiirfilter \ elements/audioamplify \ - elements/audioreverb \ + elements/audioecho \ elements/audiodynamic \ elements/audiowsincband \ elements/audiowsinclimit \ diff --git a/tests/check/elements/audioecho.c b/tests/check/elements/audioecho.c new file mode 100644 index 00000000..aa259a21 --- /dev/null +++ b/tests/check/elements/audioecho.c @@ -0,0 +1,229 @@ +/* GStreamer + * + * Copyright (C) 2009 Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +gboolean have_eos = FALSE; + +/* For ease of programming we use globals to keep refs for our floating + * src and sink pads we create; otherwise we always have to do get_pad, + * get_peer, and then remove references in every test function */ +GstPad *mysrcpad, *mysinkpad; + +#define ECHO_CAPS_STRING \ + "audio/x-raw-float, " \ + "channels = (int) 2, " \ + "rate = (int) 100000, " \ + "endianness = (int) BYTE_ORDER, " \ + "width = (int) 64" + +static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-float, " + "channels = (int) [ 1, 2 ], " + "rate = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }") + ); +static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-float, " + "channels = (int) [ 1, 2 ], " + "rate = (int) [ 1, MAX ], " + "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }") + ); + +GstElement * +setup_echo () +{ + GstElement *echo; + + GST_DEBUG ("setup_echo"); + echo = gst_check_setup_element ("audioecho"); + mysrcpad = gst_check_setup_src_pad (echo, &srctemplate, NULL); + mysinkpad = gst_check_setup_sink_pad (echo, &sinktemplate, NULL); + gst_pad_set_active (mysrcpad, TRUE); + gst_pad_set_active (mysinkpad, TRUE); + + return echo; +} + +void +cleanup_echo (GstElement * echo) +{ + GST_DEBUG ("cleanup_echo"); + + g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); + g_list_free (buffers); + buffers = NULL; + + gst_pad_set_active (mysrcpad, FALSE); + gst_pad_set_active (mysinkpad, FALSE); + gst_check_teardown_src_pad (echo); + gst_check_teardown_sink_pad (echo); + gst_check_teardown_element (echo); +} + +GST_START_TEST (test_passthrough) +{ + GstElement *echo; + GstBuffer *inbuffer, *outbuffer; + GstCaps *caps; + gdouble in[] = { 1.0, -1.0, 0.0, 0.5, -0.5, 0.0 }; + gdouble *res; + + echo = setup_echo (); + g_object_set (G_OBJECT (echo), "delay", 1, "intensity", 0.0, "feedback", + 0.0, NULL); + fail_unless (gst_element_set_state (echo, + GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, + "could not set to playing"); + + inbuffer = gst_buffer_new_and_alloc (sizeof (in)); + memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in)); + fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0); + caps = gst_caps_from_string (ECHO_CAPS_STRING); + gst_buffer_set_caps (inbuffer, caps); + gst_caps_unref (caps); + ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); + + /* pushing gives away my reference ... */ + fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); + /* ... but it ends up being collected on the global buffer list */ + fail_unless_equals_int (g_list_length (buffers), 1); + fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); + + res = (gdouble *) GST_BUFFER_DATA (outbuffer); + GST_INFO + ("expected %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf", + in[0], in[1], in[2], in[3], in[4], in[5], res[0], res[1], res[2], res[3], + res[4], res[5]); + fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, sizeof (in)) == 0); + + /* cleanup */ + cleanup_echo (echo); +} + +GST_END_TEST; + +GST_START_TEST (test_echo) +{ + GstElement *echo; + GstBuffer *inbuffer, *outbuffer; + GstCaps *caps; + gdouble in[] = { 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, }; + gdouble out[] = { 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0 }; + gdouble *res; + + echo = setup_echo (); + g_object_set (G_OBJECT (echo), "delay", 20000, "intensity", 1.0, "feedback", + 0.0, NULL); + fail_unless (gst_element_set_state (echo, + GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, + "could not set to playing"); + + inbuffer = gst_buffer_new_and_alloc (sizeof (in)); + memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in)); + fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0); + caps = gst_caps_from_string (ECHO_CAPS_STRING); + gst_buffer_set_caps (inbuffer, caps); + gst_caps_unref (caps); + ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); + + /* pushing gives away my reference ... */ + fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); + /* ... but it ends up being collected on the global buffer list */ + fail_unless_equals_int (g_list_length (buffers), 1); + fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); + + res = (gdouble *) GST_BUFFER_DATA (outbuffer); + GST_INFO + ("expected %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf", + out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8], + out[9], res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7], + res[8], res[9]); + fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, sizeof (out)) == 0); + + /* cleanup */ + cleanup_echo (echo); +} + +GST_END_TEST; + +GST_START_TEST (test_feedback) +{ + GstElement *echo; + GstBuffer *inbuffer, *outbuffer; + GstCaps *caps; + gdouble in[] = { 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, }; + gdouble out[] = { 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 1.0, -1.0 }; + gdouble *res; + + echo = setup_echo (); + g_object_set (G_OBJECT (echo), "delay", 20000, "intensity", 1.0, "feedback", + 1.0, NULL); + fail_unless (gst_element_set_state (echo, + GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, + "could not set to playing"); + + inbuffer = gst_buffer_new_and_alloc (sizeof (in)); + memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in)); + fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0); + caps = gst_caps_from_string (ECHO_CAPS_STRING); + gst_buffer_set_caps (inbuffer, caps); + gst_caps_unref (caps); + ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); + + /* pushing gives away my reference ... */ + fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); + /* ... but it ends up being collected on the global buffer list */ + fail_unless_equals_int (g_list_length (buffers), 1); + fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); + + res = (gdouble *) GST_BUFFER_DATA (outbuffer); + GST_INFO + ("expected %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf", + out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8], + out[9], res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7], + res[8], res[9]); + fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, sizeof (out)) == 0); + + /* cleanup */ + cleanup_echo (echo); +} + +GST_END_TEST; + +static Suite * +audioecho_suite (void) +{ + Suite *s = suite_create ("audioecho"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_passthrough); + tcase_add_test (tc_chain, test_echo); + tcase_add_test (tc_chain, test_feedback); + + return s; +} + +GST_CHECK_MAIN (audioecho); diff --git a/tests/check/elements/audioreverb.c b/tests/check/elements/audioreverb.c deleted file mode 100644 index cafe8bbe..00000000 --- a/tests/check/elements/audioreverb.c +++ /dev/null @@ -1,229 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2009 Sebastian Dröge - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -gboolean have_eos = FALSE; - -/* For ease of programming we use globals to keep refs for our floating - * src and sink pads we create; otherwise we always have to do get_pad, - * get_peer, and then remove references in every test function */ -GstPad *mysrcpad, *mysinkpad; - -#define REVERB_CAPS_STRING \ - "audio/x-raw-float, " \ - "channels = (int) 2, " \ - "rate = (int) 100000, " \ - "endianness = (int) BYTE_ORDER, " \ - "width = (int) 64" - -static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " - "channels = (int) [ 1, 2 ], " - "rate = (int) [ 1, MAX ], " - "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }") - ); -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " - "channels = (int) [ 1, 2 ], " - "rate = (int) [ 1, MAX ], " - "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }") - ); - -GstElement * -setup_reverb () -{ - GstElement *reverb; - - GST_DEBUG ("setup_reverb"); - reverb = gst_check_setup_element ("audioreverb"); - mysrcpad = gst_check_setup_src_pad (reverb, &srctemplate, NULL); - mysinkpad = gst_check_setup_sink_pad (reverb, &sinktemplate, NULL); - gst_pad_set_active (mysrcpad, TRUE); - gst_pad_set_active (mysinkpad, TRUE); - - return reverb; -} - -void -cleanup_reverb (GstElement * reverb) -{ - GST_DEBUG ("cleanup_reverb"); - - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - - gst_pad_set_active (mysrcpad, FALSE); - gst_pad_set_active (mysinkpad, FALSE); - gst_check_teardown_src_pad (reverb); - gst_check_teardown_sink_pad (reverb); - gst_check_teardown_element (reverb); -} - -GST_START_TEST (test_passthrough) -{ - GstElement *reverb; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - gdouble in[] = { 1.0, -1.0, 0.0, 0.5, -0.5, 0.0 }; - gdouble *res; - - reverb = setup_reverb (); - g_object_set (G_OBJECT (reverb), "delay", 1, "intensity", 0.0, "feedback", - 0.0, NULL); - fail_unless (gst_element_set_state (reverb, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - inbuffer = gst_buffer_new_and_alloc (sizeof (in)); - memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in)); - fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0); - caps = gst_caps_from_string (REVERB_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference ... */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - /* ... but it ends up being collected on the global buffer list */ - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - - res = (gdouble *) GST_BUFFER_DATA (outbuffer); - GST_INFO - ("expected %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf", - in[0], in[1], in[2], in[3], in[4], in[5], res[0], res[1], res[2], res[3], - res[4], res[5]); - fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, sizeof (in)) == 0); - - /* cleanup */ - cleanup_reverb (reverb); -} - -GST_END_TEST; - -GST_START_TEST (test_reverb) -{ - GstElement *reverb; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - gdouble in[] = { 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, }; - gdouble out[] = { 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0 }; - gdouble *res; - - reverb = setup_reverb (); - g_object_set (G_OBJECT (reverb), "delay", 20000, "intensity", 1.0, "feedback", - 0.0, NULL); - fail_unless (gst_element_set_state (reverb, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - inbuffer = gst_buffer_new_and_alloc (sizeof (in)); - memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in)); - fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0); - caps = gst_caps_from_string (REVERB_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference ... */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - /* ... but it ends up being collected on the global buffer list */ - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - - res = (gdouble *) GST_BUFFER_DATA (outbuffer); - GST_INFO - ("expected %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf", - out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8], - out[9], res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7], - res[8], res[9]); - fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, sizeof (out)) == 0); - - /* cleanup */ - cleanup_reverb (reverb); -} - -GST_END_TEST; - -GST_START_TEST (test_feedback) -{ - GstElement *reverb; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - gdouble in[] = { 1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, }; - gdouble out[] = { 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 1.0, -1.0 }; - gdouble *res; - - reverb = setup_reverb (); - g_object_set (G_OBJECT (reverb), "delay", 20000, "intensity", 1.0, "feedback", - 1.0, NULL); - fail_unless (gst_element_set_state (reverb, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - inbuffer = gst_buffer_new_and_alloc (sizeof (in)); - memcpy (GST_BUFFER_DATA (inbuffer), in, sizeof (in)); - fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, sizeof (in)) == 0); - caps = gst_caps_from_string (REVERB_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference ... */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - /* ... but it ends up being collected on the global buffer list */ - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - - res = (gdouble *) GST_BUFFER_DATA (outbuffer); - GST_INFO - ("expected %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf real %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf %+lf", - out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7], out[8], - out[9], res[0], res[1], res[2], res[3], res[4], res[5], res[6], res[7], - res[8], res[9]); - fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, sizeof (out)) == 0); - - /* cleanup */ - cleanup_reverb (reverb); -} - -GST_END_TEST; - -static Suite * -audioreverb_suite (void) -{ - Suite *s = suite_create ("audioreverb"); - TCase *tc_chain = tcase_create ("general"); - - suite_add_tcase (s, tc_chain); - tcase_add_test (tc_chain, test_passthrough); - tcase_add_test (tc_chain, test_reverb); - tcase_add_test (tc_chain, test_feedback); - - return s; -} - -GST_CHECK_MAIN (audioreverb); -- cgit