summaryrefslogtreecommitdiffstats
path: root/tests/icles
diff options
context:
space:
mode:
authorWouter Paesen <wouter@kangaroot.net>2006-06-14 18:07:51 +0000
committerTim-Philipp Müller <tim@centricular.net>2006-06-14 18:07:51 +0000
commit34f03fe525ac9c9e646ac77b9b0b655bd46d433b (patch)
tree9fc3d837bc70e7ffc468e796146c5620499e53e9 /tests/icles
parentbed0b905a19551aa9cfec0dcfd1f744c1576c5a1 (diff)
downloadgst-plugins-bad-34f03fe525ac9c9e646ac77b9b0b655bd46d433b.tar.gz
gst-plugins-bad-34f03fe525ac9c9e646ac77b9b0b655bd46d433b.tar.bz2
gst-plugins-bad-34f03fe525ac9c9e646ac77b9b0b655bd46d433b.zip
ext/soundtouch/: Make pitch element controllable via GstController interface (#344821).
Original commit message from CVS: Patch by: Wouter Paesen <wouter at kangaroot net> * ext/soundtouch/Makefile.am: * ext/soundtouch/gstpitch.cc: Make pitch element controllable via GstController interface (#344821). * configure.ac: Up core requirements to 0.10.8.1/CVS because earlier GstControllers can't handle float properties correctly. Check for GstController CFLAGS and LIBS. * tests/icles/Makefile.am: * tests/icles/pitch-test.c: (main): Add small test program for the above (welcome to the 80s!).
Diffstat (limited to 'tests/icles')
-rw-r--r--tests/icles/Makefile.am15
-rw-r--r--tests/icles/pitch-test.c99
2 files changed, 113 insertions, 1 deletions
diff --git a/tests/icles/Makefile.am b/tests/icles/Makefile.am
index e3018d30..e1920fd2 100644
--- a/tests/icles/Makefile.am
+++ b/tests/icles/Makefile.am
@@ -12,5 +12,18 @@ else
GST_V4L2_TESTS =
endif
-noinst_PROGRAMS = $(GST_V4L2_TESTS)
+if USE_SOUNDTOUCH
+
+GST_SOUNDTOUCH_TESTS = pitch-test
+
+pitch_test_SOURCES = pitch-test.c
+pitch_test_CFLAGS = $(GST_CONTROLLER_CFLAGS)
+pitch_test_LDADD = $(GST_CONTROLLER_LIBS)
+pitch_test_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+
+else
+GST_SOUNDTOUCH_TESTS =
+endif
+
+noinst_PROGRAMS = $(GST_V4L2_TESTS) $(GST_SOUNDTOUCH_TESTS)
diff --git a/tests/icles/pitch-test.c b/tests/icles/pitch-test.c
new file mode 100644
index 00000000..7fe2b94e
--- /dev/null
+++ b/tests/icles/pitch-test.c
@@ -0,0 +1,99 @@
+/* GStreamer
+ *
+ * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
+ *
+ * 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.
+ */
+
+/* compile with :
+ * gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10 gstreamer-controller-0.10) pitch.c -o pitch
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <gst/gst.h>
+#include <gst/controller/gstcontroller.h>
+
+int
+main (int argc, char **argv)
+{
+ GMainLoop *loop;
+ gint i;
+
+ GstElement *audiotestsrc;
+ GstElement *audioconvert1, *audioconvert2;
+ GstElement *pitch;
+ GstElement *sink;
+ GstElement *pipeline;
+ GstController *ctl;
+ GValue val = { 0, };
+
+ if (argc != 2) {
+ g_printerr ("Usage: %s <audiosink>\n", argv[0]);
+ return 1;
+ }
+
+ /* initialize GStreamer */
+ gst_init (&argc, &argv);
+ gst_controller_init (&argc, &argv);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ pipeline = gst_pipeline_new ("audio-player");
+ audiotestsrc = gst_element_factory_make ("audiotestsrc", "audiotestsrc");
+ g_assert (audiotestsrc != NULL);
+ audioconvert1 = gst_element_factory_make ("audioconvert", "audioconvert1");
+ g_assert (audioconvert1 != NULL);
+ audioconvert2 = gst_element_factory_make ("audioconvert", "audioconvert2");
+ g_assert (audioconvert2 != NULL);
+ pitch = gst_element_factory_make ("pitch", "pitch");
+ g_assert (pitch != NULL);
+ sink = gst_element_factory_make (argv[1], "sink");
+ g_assert (sink != NULL);
+
+ gst_bin_add_many (GST_BIN (pipeline),
+ audiotestsrc, audioconvert1, pitch, audioconvert2, sink, NULL);
+ gst_element_link_many (audiotestsrc, audioconvert1, pitch, audioconvert2,
+ sink, NULL);
+
+ ctl = gst_object_control_properties (G_OBJECT (pitch), "pitch", NULL);
+ gst_controller_set_interpolation_mode (ctl, "pitch", GST_INTERPOLATE_LINEAR);
+
+ g_value_init (&val, G_TYPE_FLOAT);
+
+ for (i = 0; i < 100; ++i) {
+ if (i % 2)
+ g_value_set_float (&val, 0.5);
+ else
+ g_value_set_float (&val, 1.5);
+
+ gst_controller_set (ctl, "pitch", i * GST_SECOND, &val);
+ }
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ g_print ("Running\n");
+ g_main_loop_run (loop);
+
+ /* set up a controller */
+
+ /* clean up nicely */
+ g_print ("Returned, stopping playback\n");
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ g_print ("Deleting pipeline\n");
+ gst_object_unref (GST_OBJECT (pipeline));
+
+ return 0;
+}