From 34f03fe525ac9c9e646ac77b9b0b655bd46d433b Mon Sep 17 00:00:00 2001 From: Wouter Paesen Date: Wed, 14 Jun 2006 18:07:51 +0000 Subject: ext/soundtouch/: Make pitch element controllable via GstController interface (#344821). Original commit message from CVS: Patch by: Wouter Paesen * 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!). --- ChangeLog | 18 +++++++++ configure.ac | 4 +- ext/soundtouch/Makefile.am | 6 +-- ext/soundtouch/gstpitch.cc | 11 ++++-- tests/icles/Makefile.am | 15 ++++++- tests/icles/pitch-test.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 144 insertions(+), 9 deletions(-) create mode 100644 tests/icles/pitch-test.c diff --git a/ChangeLog b/ChangeLog index df386aea..41560021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2006-06-14 Tim-Philipp Müller + + Patch by: Wouter Paesen + + * 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!). + 2006-06-14 Tim-Philipp Müller Patch by: Sebastian Dröge diff --git a/configure.ac b/configure.ac index cc1f90b2..ae307b75 100644 --- a/configure.ac +++ b/configure.ac @@ -42,7 +42,7 @@ dnl AS_LIBTOOL_TAGS([CXX]) AM_PROG_LIBTOOL dnl *** required versions of GStreamer stuff *** -GST_REQ=0.10.6.1 +GST_REQ=0.10.8.1 GSTPB_REQ=0.10.3 dnl *** autotools stuff **** @@ -158,8 +158,8 @@ GST_CHECK_GST($GST_MAJORMINOR, [$GST_REQ]) GST_CHECK_GST_BASE($GST_MAJORMINOR, [$GST_REQ]) GST_CHECK_GST_GDP($GST_MAJORMINOR, [$GST_REQ]) GST_CHECK_GST_CHECK($GST_MAJORMINOR, [$GST_REQ], no) +GST_CHECK_GST_CONTROLLER($GST_MAJORMINOR, [$GST_REQ]) GST_CHECK_GST_PLUGINS_BASE($GST_MAJORMINOR, [$GSTPB_REQ], no) - GSTPB_PLUGINS_DIR=`$PKG_CONFIG gstreamer-plugins-base-$GST_MAJORMINOR --variable pluginsdir` AC_SUBST(GSTPB_PLUGINS_DIR) AC_MSG_NOTICE(Using GStreamer Base Plugins in $GSTPB_PLUGINS_DIR) diff --git a/ext/soundtouch/Makefile.am b/ext/soundtouch/Makefile.am index d286bfce..e7523bfb 100644 --- a/ext/soundtouch/Makefile.am +++ b/ext/soundtouch/Makefile.am @@ -2,8 +2,8 @@ plugin_LTLIBRARIES = libgstpitch.la libgstpitch_la_SOURCES = gstpitch.cc -libgstpitch_la_CXXFLAGS = @GST_CFLAGS@ @GST_BASE_CFLAGS@ @SOUNDTOUCH_CFLAGS@ -libgstpitch_la_LIBADD = @GST_LIBS@ @GST_BASE_LIBS@ @SOUNDTOUCH_LIBS@ -libgstpitch_la_LDFLAGS = @GST_PLUGIN_LDFLAGS@ +libgstpitch_la_CXXFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(SOUNDTOUCH_CFLAGS) $(GST_CONTROLLER_CFLAGS) +libgstpitch_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(SOUNDTOUCH_LIBS) $(GST_CONTROLLER_LIBS) +libgstpitch_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) noinst_HEADERS = gstpitch.hh diff --git a/ext/soundtouch/gstpitch.cc b/ext/soundtouch/gstpitch.cc index c0040865..8b09c2c4 100644 --- a/ext/soundtouch/gstpitch.cc +++ b/ext/soundtouch/gstpitch.cc @@ -22,6 +22,7 @@ #endif #include +#include #include "gstpitch.hh" #include @@ -136,17 +137,17 @@ gst_pitch_class_init (GstPitchClass * klass) g_object_class_install_property (gobject_class, ARG_PITCH, g_param_spec_float ("pitch", "Pitch", "Audio stream pitch", 0.1, 10.0, 1.0, - (GParamFlags) G_PARAM_READWRITE)); + (GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE))); g_object_class_install_property (gobject_class, ARG_TEMPO, g_param_spec_float ("tempo", "Tempo", "Audio stream tempo", 0.1, 10.0, 1.0, - (GParamFlags) G_PARAM_READWRITE)); + (GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE))); g_object_class_install_property (gobject_class, ARG_RATE, g_param_spec_float ("rate", "Rate", "Audio stream rate", 0.1, 10.0, 1.0, - (GParamFlags) G_PARAM_READWRITE)); + (GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE))); g_type_class_add_private (gobject_class, sizeof (GstPitchPrivate)); } @@ -640,6 +641,8 @@ gst_pitch_chain (GstPad * pad, GstBuffer * buffer) pitch = GST_PITCH (GST_PAD_PARENT (pad)); priv = GST_PITCH_GET_PRIVATE (pitch); + gst_object_sync_values (G_OBJECT (pitch), pitch->next_buffer_time); + /* push the received samples on the soundtouch buffer */ GST_LOG_OBJECT (pitch, "incoming buffer (%d samples)", (gint) (GST_BUFFER_SIZE (buffer) / pitch->sample_size)); @@ -696,6 +699,8 @@ gst_pitch_change_state (GstElement * element, GstStateChange transition) static gboolean plugin_init (GstPlugin * plugin) { + gst_controller_init (NULL, NULL); + GST_DEBUG_CATEGORY_INIT (pitch_debug, "pitch", 0, "audio pitch control element"); 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 + * + * 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 +#include +#include +#include + +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 \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; +} -- cgit v1.2.1