+2006-06-14 Tim-Philipp Müller <tim at centricular dot net>
+
+ 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!).
+
2006-06-14 Tim-Philipp Müller <tim at centricular dot net>
Patch by: Sebastian Dröge <slomo at circular-chaos org>
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 ****
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)
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
#endif
#include <gst/gst.h>
+#include <gst/controller/gstcontroller.h>
#include "gstpitch.hh"
#include <math.h>
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));
}
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));
static gboolean
plugin_init (GstPlugin * plugin)
{
+ gst_controller_init (NULL, NULL);
+
GST_DEBUG_CATEGORY_INIT (pitch_debug, "pitch", 0,
"audio pitch control element");
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)
--- /dev/null
+/* 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;
+}