Index: libs/gst/controller/Makefile.am
===================================================================
RCS file: /cvs/gstreamer/gstreamer/libs/gst/controller/Makefile.am,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 Makefile.am
--- libs/gst/controller/Makefile.am	6 Jul 2007 21:50:02 -0000	1.8
+++ libs/gst/controller/Makefile.am	24 Jul 2007 03:37:40 -0000
@@ -4,7 +4,8 @@ libgstcontroller_@GST_MAJORMINOR@_includ
 libgstcontroller_@GST_MAJORMINOR@_include_HEADERS = \
 	gstcontroller.h \
 	gstcontrolsource.h \
-	gstinterpolationcontrolsource.h
+	gstinterpolationcontrolsource.h \
+	gstlfocontrolsource.h
 
 noinst_HEADERS = \
 	gstcontrollerprivate.h \
@@ -16,7 +17,8 @@ libgstcontroller_@GST_MAJORMINOR@_la_SOU
 	gstinterpolation.c \
 	gsthelper.c \
 	gstcontrolsource.c \
-	gstinterpolationcontrolsource.c
+	gstinterpolationcontrolsource.c \
+	gstlfocontrolsource.c
 
 libgstcontroller_@GST_MAJORMINOR@_la_CFLAGS = $(GST_OBJ_CFLAGS)
 libgstcontroller_@GST_MAJORMINOR@_la_LIBADD = $(GST_OBJ_LIBS)
Index: libs/gst/controller/gstlfocontrolsource.c
===================================================================
RCS file: libs/gst/controller/gstlfocontrolsource.c
diff -N libs/gst/controller/gstlfocontrolsource.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libs/gst/controller/gstlfocontrolsource.c	24 Jul 2007 03:37:43 -0000
@@ -0,0 +1,1124 @@
+/* GStreamer
+ *
+ * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
+ *
+ * gstlfocontrolsource.c: Control source that provides some periodic waveforms
+ *                        as control values.
+ *
+ * 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:gstlfocontrolsource
+ * @short_description: LFO control source
+ *
+ * #GstLFOControlSource is a #GstControlSource, that provides several periodic waveforms
+ * as control values. It supports all fundamental, numeric GValue types as property.
+ *
+ * To use #GstLFOControlSource get a new instance by calling gst_lfo_control_source_new(),
+ * bind it to a #GParamSpec and set the relevant properties or use
+ * gst_lfo_control_source_set_waveform.
+ *
+ * All functions are MT-safe.
+ *
+ */
+
+#include <glib-object.h>
+#include <gst/gst.h>
+
+#include "gstcontrolsource.h"
+#include "gstlfocontrolsource.h"
+#include "gstlfocontrolsourceprivate.h"
+
+#include "math.h"
+
+/* FIXME: as % in C is not the modulo operator we need here for
+ * negative numbers implement our own. Are there better ways? */
+static inline GstClockTime
+_calculate_pos (GstClockTime timestamp, GstClockTime timeshift, GstClockTime period)
+{
+  while (timestamp < timeshift)
+    timestamp += period;
+  
+  timestamp -= timeshift;
+
+  return timestamp % period;
+}
+
+#define DEFINE_SINE(type,round) \
+\
+static inline g##type \
+_sine_get_##type (GstLFOControlSource *self, GstClockTime timestamp) \
+{ \
+  gdouble ret; \
+  g##type max = g_value_get_##type (&self->priv->maximum_value); \
+  g##type min = g_value_get_##type (&self->priv->minimum_value); \
+  gdouble amp = g_value_get_##type (&self->priv->amplitude); \
+  gdouble off = g_value_get_##type (&self->priv->offset); \
+  GstClockTime pos = _calculate_pos (timestamp, self->priv->timeshift, self->priv->period); \
+  \
+  ret = sin (2.0 * M_PI * (self->priv->frequency / GST_SECOND) * pos); \
+  ret *= amp; \
+  ret += off; \
+  \
+  if (round) \
+    ret += 0.5; \
+  \
+  return (g##type) CLAMP (ret, min, max); \
+} \
+\
+static gboolean \
+waveform_sine_get_##type (GstLFOControlSource *self, GstClockTime timestamp, \
+    GValue *value) \
+{ \
+  g##type ret; \
+  g_mutex_lock (self->lock); \
+  ret = _sine_get_##type (self, timestamp); \
+  g_value_set_##type (value, ret); \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+} \
+\
+static gboolean \
+waveform_sine_get_##type##_value_array (GstLFOControlSource *self, \
+   GstClockTime timestamp, GstValueArray * value_array) \
+{ \
+  gint i; \
+  GstClockTime ts = timestamp; \
+  g##type *values = (g##type *) value_array->values; \
+  \
+  g_mutex_lock (self->lock); \
+  for(i = 0; i < value_array->nbsamples; i++) { \
+    *values = _sine_get_##type (self, ts); \
+    ts += value_array->sample_interval; \
+    values++; \
+  } \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+}
+
+DEFINE_SINE(int, TRUE);
+DEFINE_SINE(uint, TRUE);
+DEFINE_SINE(long, TRUE);
+DEFINE_SINE(ulong, TRUE);
+DEFINE_SINE(int64, TRUE);
+DEFINE_SINE(uint64, TRUE);
+DEFINE_SINE(float, FALSE);
+DEFINE_SINE(double, FALSE);
+
+static GstWaveformImplementation waveform_sine = {
+(GstControlSourceGetValue) waveform_sine_get_int,
+(GstControlSourceGetValueArray) waveform_sine_get_int_value_array,
+(GstControlSourceGetValue) waveform_sine_get_uint,
+(GstControlSourceGetValueArray) waveform_sine_get_uint_value_array,
+(GstControlSourceGetValue) waveform_sine_get_long,
+(GstControlSourceGetValueArray) waveform_sine_get_long_value_array,
+(GstControlSourceGetValue) waveform_sine_get_ulong,
+(GstControlSourceGetValueArray) waveform_sine_get_ulong_value_array,
+(GstControlSourceGetValue) waveform_sine_get_int64,
+(GstControlSourceGetValueArray) waveform_sine_get_int64_value_array,
+(GstControlSourceGetValue) waveform_sine_get_uint64,
+(GstControlSourceGetValueArray) waveform_sine_get_uint64_value_array,
+(GstControlSourceGetValue) waveform_sine_get_float,
+(GstControlSourceGetValueArray) waveform_sine_get_float_value_array,
+(GstControlSourceGetValue) waveform_sine_get_double,
+(GstControlSourceGetValueArray) waveform_sine_get_double_value_array
+};
+
+#define DEFINE_SQUARE(type,round) \
+\
+static inline g##type \
+_square_get_##type (GstLFOControlSource *self, GstClockTime timestamp) \
+{ \
+  g##type max = g_value_get_##type (&self->priv->maximum_value); \
+  g##type min = g_value_get_##type (&self->priv->minimum_value); \
+  gdouble amp = g_value_get_##type (&self->priv->amplitude); \
+  gdouble off = g_value_get_##type (&self->priv->offset); \
+  GstClockTime period = self->priv->period; \
+  GstClockTime pos = _calculate_pos (timestamp, self->priv->timeshift, period); \
+  gdouble ret; \
+  \
+  if (pos >= period / 2) \
+    ret = amp; \
+  else \
+    ret = - amp; \
+  \
+  ret += off; \
+  \
+  if (round) \
+    ret += 0.5; \
+  \
+  return (g##type) CLAMP (ret, min, max); \
+} \
+\
+static gboolean \
+waveform_square_get_##type (GstLFOControlSource *self, GstClockTime timestamp, \
+    GValue *value) \
+{ \
+  g##type ret; \
+  g_mutex_lock (self->lock); \
+  ret = _square_get_##type (self, timestamp); \
+  g_value_set_##type (value, ret); \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+} \
+\
+static gboolean \
+waveform_square_get_##type##_value_array (GstLFOControlSource *self, \
+   GstClockTime timestamp, GstValueArray * value_array) \
+{ \
+  gint i; \
+  GstClockTime ts = timestamp; \
+  g##type *values = (g##type *) value_array->values; \
+  \
+  g_mutex_lock (self->lock); \
+  for(i = 0; i < value_array->nbsamples; i++) { \
+    *values = _square_get_##type (self, ts); \
+    ts += value_array->sample_interval; \
+    values++; \
+  } \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+}
+
+DEFINE_SQUARE(int, TRUE);
+DEFINE_SQUARE(uint, TRUE);
+DEFINE_SQUARE(long, TRUE);
+DEFINE_SQUARE(ulong, TRUE);
+DEFINE_SQUARE(int64, TRUE);
+DEFINE_SQUARE(uint64, TRUE);
+DEFINE_SQUARE(float, FALSE);
+DEFINE_SQUARE(double, FALSE);
+
+static GstWaveformImplementation waveform_square = {
+(GstControlSourceGetValue) waveform_square_get_int,
+(GstControlSourceGetValueArray) waveform_square_get_int_value_array,
+(GstControlSourceGetValue) waveform_square_get_uint,
+(GstControlSourceGetValueArray) waveform_square_get_uint_value_array,
+(GstControlSourceGetValue) waveform_square_get_long,
+(GstControlSourceGetValueArray) waveform_square_get_long_value_array,
+(GstControlSourceGetValue) waveform_square_get_ulong,
+(GstControlSourceGetValueArray) waveform_square_get_ulong_value_array,
+(GstControlSourceGetValue) waveform_square_get_int64,
+(GstControlSourceGetValueArray) waveform_square_get_int64_value_array,
+(GstControlSourceGetValue) waveform_square_get_uint64,
+(GstControlSourceGetValueArray) waveform_square_get_uint64_value_array,
+(GstControlSourceGetValue) waveform_square_get_float,
+(GstControlSourceGetValueArray) waveform_square_get_float_value_array,
+(GstControlSourceGetValue) waveform_square_get_double,
+(GstControlSourceGetValueArray) waveform_square_get_double_value_array
+};
+
+#define DEFINE_SAW(type,round) \
+\
+static inline g##type \
+_saw_get_##type (GstLFOControlSource *self, GstClockTime timestamp) \
+{ \
+  g##type max = g_value_get_##type (&self->priv->maximum_value); \
+  g##type min = g_value_get_##type (&self->priv->minimum_value); \
+  gdouble amp = g_value_get_##type (&self->priv->amplitude); \
+  gdouble off = g_value_get_##type (&self->priv->offset); \
+  GstClockTime period = self->priv->period; \
+  GstClockTime pos = _calculate_pos (timestamp, self->priv->timeshift, period); \
+  gdouble ret; \
+  \
+  ret = - ((pos - period / 2.0) * ((2.0 * amp) / period));\
+  \
+  ret += off; \
+  \
+  if (round) \
+    ret += 0.5; \
+  \
+  return (g##type) CLAMP (ret, min, max); \
+} \
+\
+static gboolean \
+waveform_saw_get_##type (GstLFOControlSource *self, GstClockTime timestamp, \
+    GValue *value) \
+{ \
+  g##type ret; \
+  g_mutex_lock (self->lock); \
+  ret = _saw_get_##type (self, timestamp); \
+  g_value_set_##type (value, ret); \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+} \
+\
+static gboolean \
+waveform_saw_get_##type##_value_array (GstLFOControlSource *self, \
+   GstClockTime timestamp, GstValueArray * value_array) \
+{ \
+  gint i; \
+  GstClockTime ts = timestamp; \
+  g##type *values = (g##type *) value_array->values; \
+  \
+  g_mutex_lock (self->lock); \
+  for(i = 0; i < value_array->nbsamples; i++) { \
+    *values = _saw_get_##type (self, ts); \
+    ts += value_array->sample_interval; \
+    values++; \
+  } \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+}
+
+DEFINE_SAW(int, TRUE);
+DEFINE_SAW(uint, TRUE);
+DEFINE_SAW(long, TRUE);
+DEFINE_SAW(ulong, TRUE);
+DEFINE_SAW(int64, TRUE);
+DEFINE_SAW(uint64, TRUE);
+DEFINE_SAW(float, FALSE);
+DEFINE_SAW(double, FALSE);
+
+static GstWaveformImplementation waveform_saw = {
+(GstControlSourceGetValue) waveform_saw_get_int,
+(GstControlSourceGetValueArray) waveform_saw_get_int_value_array,
+(GstControlSourceGetValue) waveform_saw_get_uint,
+(GstControlSourceGetValueArray) waveform_saw_get_uint_value_array,
+(GstControlSourceGetValue) waveform_saw_get_long,
+(GstControlSourceGetValueArray) waveform_saw_get_long_value_array,
+(GstControlSourceGetValue) waveform_saw_get_ulong,
+(GstControlSourceGetValueArray) waveform_saw_get_ulong_value_array,
+(GstControlSourceGetValue) waveform_saw_get_int64,
+(GstControlSourceGetValueArray) waveform_saw_get_int64_value_array,
+(GstControlSourceGetValue) waveform_saw_get_uint64,
+(GstControlSourceGetValueArray) waveform_saw_get_uint64_value_array,
+(GstControlSourceGetValue) waveform_saw_get_float,
+(GstControlSourceGetValueArray) waveform_saw_get_float_value_array,
+(GstControlSourceGetValue) waveform_saw_get_double,
+(GstControlSourceGetValueArray) waveform_saw_get_double_value_array
+};
+
+#define DEFINE_RSAW(type,round) \
+\
+static inline g##type \
+_rsaw_get_##type (GstLFOControlSource *self, GstClockTime timestamp) \
+{ \
+  g##type max = g_value_get_##type (&self->priv->maximum_value); \
+  g##type min = g_value_get_##type (&self->priv->minimum_value); \
+  gdouble amp = g_value_get_##type (&self->priv->amplitude); \
+  gdouble off = g_value_get_##type (&self->priv->offset); \
+  GstClockTime period = self->priv->period; \
+  GstClockTime pos = _calculate_pos (timestamp, self->priv->timeshift, period); \
+  gdouble ret; \
+  \
+  ret = ((pos - period / 2.0) * ((2.0 * amp) / period));\
+  \
+  ret += off; \
+  \
+  if (round) \
+    ret += 0.5; \
+  \
+  return (g##type) CLAMP (ret, min, max); \
+} \
+\
+static gboolean \
+waveform_rsaw_get_##type (GstLFOControlSource *self, GstClockTime timestamp, \
+    GValue *value) \
+{ \
+  g##type ret; \
+  g_mutex_lock (self->lock); \
+  ret = _rsaw_get_##type (self, timestamp); \
+  g_value_set_##type (value, ret); \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+} \
+\
+static gboolean \
+waveform_rsaw_get_##type##_value_array (GstLFOControlSource *self, \
+   GstClockTime timestamp, GstValueArray * value_array) \
+{ \
+  gint i; \
+  GstClockTime ts = timestamp; \
+  g##type *values = (g##type *) value_array->values; \
+  \
+  g_mutex_lock (self->lock); \
+  for(i = 0; i < value_array->nbsamples; i++) { \
+    *values = _rsaw_get_##type (self, ts); \
+    ts += value_array->sample_interval; \
+    values++; \
+  } \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+}
+
+DEFINE_RSAW(int, TRUE);
+DEFINE_RSAW(uint, TRUE);
+DEFINE_RSAW(long, TRUE);
+DEFINE_RSAW(ulong, TRUE);
+DEFINE_RSAW(int64, TRUE);
+DEFINE_RSAW(uint64, TRUE);
+DEFINE_RSAW(float, FALSE);
+DEFINE_RSAW(double, FALSE);
+
+static GstWaveformImplementation waveform_rsaw = {
+(GstControlSourceGetValue) waveform_rsaw_get_int,
+(GstControlSourceGetValueArray) waveform_rsaw_get_int_value_array,
+(GstControlSourceGetValue) waveform_rsaw_get_uint,
+(GstControlSourceGetValueArray) waveform_rsaw_get_uint_value_array,
+(GstControlSourceGetValue) waveform_rsaw_get_long,
+(GstControlSourceGetValueArray) waveform_rsaw_get_long_value_array,
+(GstControlSourceGetValue) waveform_rsaw_get_ulong,
+(GstControlSourceGetValueArray) waveform_rsaw_get_ulong_value_array,
+(GstControlSourceGetValue) waveform_rsaw_get_int64,
+(GstControlSourceGetValueArray) waveform_rsaw_get_int64_value_array,
+(GstControlSourceGetValue) waveform_rsaw_get_uint64,
+(GstControlSourceGetValueArray) waveform_rsaw_get_uint64_value_array,
+(GstControlSourceGetValue) waveform_rsaw_get_float,
+(GstControlSourceGetValueArray) waveform_rsaw_get_float_value_array,
+(GstControlSourceGetValue) waveform_rsaw_get_double,
+(GstControlSourceGetValueArray) waveform_rsaw_get_double_value_array
+};
+
+#define DEFINE_TRIANGLE(type,round) \
+\
+static inline g##type \
+_triangle_get_##type (GstLFOControlSource *self, GstClockTime timestamp) \
+{ \
+  g##type max = g_value_get_##type (&self->priv->maximum_value); \
+  g##type min = g_value_get_##type (&self->priv->minimum_value); \
+  gdouble amp = g_value_get_##type (&self->priv->amplitude); \
+  gdouble off = g_value_get_##type (&self->priv->offset); \
+  GstClockTime period = self->priv->period; \
+  GstClockTime pos = _calculate_pos (timestamp, self->priv->timeshift, period); \
+  gdouble ret; \
+  \
+  if (pos <= period / 4.0) \
+    ret = pos * ((4.0 * amp) / period); \
+  else if (pos <= (3.0 * period) / 4.0) \
+    ret = -(pos - period / 2.0) * ((4.0 * amp) / period); \
+  else \
+    ret = (period - pos) * ((4.0 * amp) / period); \
+  \
+  ret += off; \
+  \
+  if (round) \
+    ret += 0.5; \
+  \
+  return (g##type) CLAMP (ret, min, max); \
+} \
+\
+static gboolean \
+waveform_triangle_get_##type (GstLFOControlSource *self, GstClockTime timestamp, \
+    GValue *value) \
+{ \
+  g##type ret; \
+  g_mutex_lock (self->lock); \
+  ret = _triangle_get_##type (self, timestamp); \
+  g_value_set_##type (value, ret); \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+} \
+\
+static gboolean \
+waveform_triangle_get_##type##_value_array (GstLFOControlSource *self, \
+   GstClockTime timestamp, GstValueArray * value_array) \
+{ \
+  gint i; \
+  GstClockTime ts = timestamp; \
+  g##type *values = (g##type *) value_array->values; \
+  \
+  g_mutex_lock (self->lock); \
+  for(i = 0; i < value_array->nbsamples; i++) { \
+    *values = _triangle_get_##type (self, ts); \
+    ts += value_array->sample_interval; \
+    values++; \
+  } \
+  g_mutex_unlock (self->lock); \
+  return TRUE; \
+}
+
+DEFINE_TRIANGLE(int, TRUE);
+DEFINE_TRIANGLE(uint, TRUE);
+DEFINE_TRIANGLE(long, TRUE);
+DEFINE_TRIANGLE(ulong, TRUE);
+DEFINE_TRIANGLE(int64, TRUE);
+DEFINE_TRIANGLE(uint64, TRUE);
+DEFINE_TRIANGLE(float, FALSE);
+DEFINE_TRIANGLE(double, FALSE);
+
+static GstWaveformImplementation waveform_triangle = {
+(GstControlSourceGetValue) waveform_triangle_get_int,
+(GstControlSourceGetValueArray) waveform_triangle_get_int_value_array,
+(GstControlSourceGetValue) waveform_triangle_get_uint,
+(GstControlSourceGetValueArray) waveform_triangle_get_uint_value_array,
+(GstControlSourceGetValue) waveform_triangle_get_long,
+(GstControlSourceGetValueArray) waveform_triangle_get_long_value_array,
+(GstControlSourceGetValue) waveform_triangle_get_ulong,
+(GstControlSourceGetValueArray) waveform_triangle_get_ulong_value_array,
+(GstControlSourceGetValue) waveform_triangle_get_int64,
+(GstControlSourceGetValueArray) waveform_triangle_get_int64_value_array,
+(GstControlSourceGetValue) waveform_triangle_get_uint64,
+(GstControlSourceGetValueArray) waveform_triangle_get_uint64_value_array,
+(GstControlSourceGetValue) waveform_triangle_get_float,
+(GstControlSourceGetValueArray) waveform_triangle_get_float_value_array,
+(GstControlSourceGetValue) waveform_triangle_get_double,
+(GstControlSourceGetValueArray) waveform_triangle_get_double_value_array
+};
+
+static GstWaveformImplementation *waveforms[] = {
+  &waveform_sine,
+  &waveform_square,
+  &waveform_saw,
+  &waveform_rsaw,
+  &waveform_triangle
+};
+
+static guint num_waveforms = G_N_ELEMENTS (waveforms);
+
+enum
+{
+  PROP_WAVEFORM = 1,
+  PROP_FREQUENCY,
+  PROP_TIMESHIFT,
+  PROP_AMPLITUDE,
+  PROP_OFFSET
+};
+
+GType
+gst_lfo_waveform_get_type (void)
+{
+  static GType gtype = 0;
+
+  if (gtype == 0) {
+    static const GEnumValue values[] = {
+      {GST_LFO_WAVEFORM_SINE, "Sine waveform (default)",
+          "sine"},
+      {GST_LFO_WAVEFORM_SQUARE, "Square waveform",
+          "square"},
+      {GST_LFO_WAVEFORM_SAW, "Saw waveform",
+          "saw"},
+      {GST_LFO_WAVEFORM_REVERSE_SAW, "Reverse saw waveform",
+          "reverse-saw"},
+      {GST_LFO_WAVEFORM_TRIANGLE, "Triangle waveform",
+          "triangle"},
+      {0, NULL, NULL}
+    };
+
+    gtype = g_enum_register_static ("GstLFOWaveform", values);
+  }
+  return gtype;
+}
+
+static void gst_lfo_control_source_init (GstLFOControlSource
+    * self);
+static void
+gst_lfo_control_source_class_init (GstLFOControlSourceClass
+    * klass);
+
+G_DEFINE_TYPE (GstLFOControlSource, gst_lfo_control_source,
+    GST_TYPE_CONTROL_SOURCE);
+
+static GObjectClass *parent_class = NULL;
+
+static void
+gst_lfo_control_source_reset (GstLFOControlSource * self)
+{
+  GstControlSource *csource = GST_CONTROL_SOURCE (self);
+
+  csource->get_value = NULL;
+  csource->get_value_array = NULL;
+
+  self->priv->type = self->priv->base = G_TYPE_INVALID;
+
+  if (G_IS_VALUE (&self->priv->minimum_value))
+    g_value_unset (&self->priv->minimum_value);
+  if (G_IS_VALUE (&self->priv->maximum_value))
+    g_value_unset (&self->priv->maximum_value);
+
+  if (G_IS_VALUE (&self->priv->amplitude))
+    g_value_unset (&self->priv->amplitude);
+  if (G_IS_VALUE (&self->priv->offset))
+    g_value_unset (&self->priv->offset);
+}
+
+/**
+ * gst_lfo_control_source_new:
+ *
+ * This returns a new, unbound #GstLFOControlSource.
+ *
+ * Returns: a new, unbound #GstLFOControlSource.
+ */
+GstLFOControlSource *
+gst_lfo_control_source_new ()
+{
+  return g_object_new (GST_TYPE_LFO_CONTROL_SOURCE, NULL);
+}
+
+static gboolean
+gst_lfo_control_source_set_waveform_internal (GstLFOControlSource *self, GstLFOWaveform waveform)
+{
+  GstControlSource *csource = GST_CONTROL_SOURCE (self);
+  gboolean ret = TRUE;
+
+  if (waveform >= num_waveforms || waveform < 0) {
+    GST_WARNING ("waveform %d invalid or not implemented yet", waveform);
+    return FALSE;
+  }
+
+  switch (self->priv->base) {
+    case G_TYPE_INT:
+      csource->get_value = waveforms[waveform]->get_int;
+      csource->get_value_array = waveforms[waveform]->get_int_value_array;
+      break;
+    case G_TYPE_UINT:{
+      csource->get_value = waveforms[waveform]->get_uint;
+      csource->get_value_array = waveforms[waveform]->get_uint_value_array;
+      break;
+    }
+    case G_TYPE_LONG:{
+      csource->get_value = waveforms[waveform]->get_long;
+      csource->get_value_array = waveforms[waveform]->get_long_value_array;
+      break;
+    }
+    case G_TYPE_ULONG:{
+      csource->get_value = waveforms[waveform]->get_ulong;
+      csource->get_value_array = waveforms[waveform]->get_ulong_value_array;
+      break;
+    }
+    case G_TYPE_INT64:{
+      csource->get_value = waveforms[waveform]->get_int64;
+      csource->get_value_array = waveforms[waveform]->get_int64_value_array;
+      break;
+    }
+    case G_TYPE_UINT64:{
+      csource->get_value = waveforms[waveform]->get_uint64;
+      csource->get_value_array = waveforms[waveform]->get_uint64_value_array;
+      break;
+    }
+    case G_TYPE_FLOAT:{
+      csource->get_value = waveforms[waveform]->get_float;
+      csource->get_value_array = waveforms[waveform]->get_float_value_array;
+      break;
+    }
+    case G_TYPE_DOUBLE:{
+      csource->get_value = waveforms[waveform]->get_double;
+      csource->get_value_array = waveforms[waveform]->get_double_value_array;
+      break;
+    }
+    default:
+      ret = FALSE;
+      break;
+  }
+  
+  if (ret)
+    self->priv->waveform = waveform;
+  else
+    GST_WARNING ("incomplete implementation for type '%d'", self->priv->type);
+
+  return ret;
+}
+
+/**
+ * gst_lfo_control_source_set_waveform:
+ * @self: The #GstLFOControlSource
+ * @waveform: #GstLFOWaveform that should be used
+ * @frequency: frequency in hZ for the waveform
+ * @timeshift: number of nanoseconds to shift the waveform to the right
+ * @amplitude: amplitude of the waveform
+ * @offset: offset of the waveform
+ *
+ * This sets the waveform that should be used with the #GstLFOControlSource.
+ *
+ * If you want a timeshift to the left just give "(GST_SECOND / frequency) - timeshift"
+ * as timeshift parameter.
+ *
+ * Returns: %TRUE if the waveform could be set, %FALSE otherwise
+ */
+
+gboolean
+gst_lfo_control_source_set_waveform (GstLFOControlSource *self, GstLFOWaveform waveform,
+    gdouble frequency, GstClockTime timeshift, GValue *amplitude, GValue *offset)
+{
+  gboolean ret = TRUE;
+
+  g_return_val_if_fail (GST_IS_LFO_CONTROL_SOURCE (self), FALSE);
+
+  if (frequency <= 0 || ((GstClockTime) (GST_SECOND / frequency)) == 0) {
+    GST_WARNING ("frequency %lf too small", frequency);
+    return FALSE;
+  }
+
+  if (!(amplitude && G_IS_VALUE (amplitude) &&
+      g_value_type_transformable (G_VALUE_TYPE (amplitude), self->priv->base)) ||
+      !(offset && G_IS_VALUE (offset) &&
+      g_value_type_transformable (G_VALUE_TYPE (offset), self->priv->base))) {
+    GST_WARNING ("incompatible amplitude or offset given");
+    return FALSE;
+  }
+
+  g_mutex_lock (self->lock);
+  ret = gst_lfo_control_source_set_waveform_internal (self, waveform);
+  
+  /* Incomplete implementation */
+  if (!ret) {
+    g_mutex_unlock (self->lock);
+    return FALSE;
+  }
+
+  self->priv->frequency = frequency;
+  self->priv->period = GST_SECOND / frequency;
+  self->priv->timeshift = timeshift;
+
+  if (G_IS_VALUE (&self->priv->amplitude))
+    g_value_unset (&self->priv->amplitude);
+  if (G_IS_VALUE (&self->priv->offset))
+    g_value_unset (&self->priv->offset);
+
+  /* Checks if this is possible are at the beginning
+   * of this function */
+  g_value_init (&self->priv->amplitude, self->priv->base);
+  g_value_transform (amplitude, &self->priv->amplitude);
+  g_value_init (&self->priv->offset, self->priv->base);
+  g_value_transform (offset, &self->priv->offset);
+
+  g_mutex_unlock (self->lock);
+
+  return TRUE;
+}
+
+static gboolean
+gst_lfo_control_source_bind (GstControlSource * source,
+    GParamSpec * pspec)
+{
+  GType type, base;
+  GstLFOControlSource *self =
+      GST_LFO_CONTROL_SOURCE (source);
+  gboolean ret = TRUE;
+
+  /* get the fundamental base type */
+  self->priv->type = base = type = G_PARAM_SPEC_VALUE_TYPE (pspec);
+  while ((type = g_type_parent (type)))
+    base = type;
+
+  self->priv->base = base;
+  /* restore type */
+  type = self->priv->type;
+  
+  switch (base) {
+    case G_TYPE_INT:{
+      GParamSpecInt *tpspec = G_PARAM_SPEC_INT (pspec);
+
+      g_value_init (&self->priv->minimum_value, type);
+      g_value_set_int (&self->priv->minimum_value, tpspec->minimum);
+      g_value_init (&self->priv->maximum_value, type);
+      g_value_set_int (&self->priv->maximum_value, tpspec->maximum);
+
+      if (!G_IS_VALUE (&self->priv->amplitude)) {
+        g_value_init (&self->priv->amplitude, type);
+	g_value_set_int (&self->priv->amplitude, 0);
+      }
+
+      if (!G_IS_VALUE (&self->priv->offset)) {
+        g_value_init (&self->priv->offset, type);
+	g_value_set_int (&self->priv->offset, tpspec->default_value);
+      }
+      break;
+    }
+    case G_TYPE_UINT:{
+      GParamSpecUInt *tpspec = G_PARAM_SPEC_UINT (pspec);
+
+      g_value_init (&self->priv->minimum_value, type);
+      g_value_set_uint (&self->priv->minimum_value, tpspec->minimum);
+      g_value_init (&self->priv->maximum_value, type);
+      g_value_set_uint (&self->priv->maximum_value, tpspec->maximum);
+
+      if (!G_IS_VALUE (&self->priv->amplitude)) {
+        g_value_init (&self->priv->amplitude, type);
+	g_value_set_uint (&self->priv->amplitude, 0);
+      }
+
+      if (!G_IS_VALUE (&self->priv->offset)) {
+        g_value_init (&self->priv->offset, type);
+	g_value_set_uint (&self->priv->offset, tpspec->default_value);
+      }
+      break;
+    }
+    case G_TYPE_LONG:{
+      GParamSpecLong *tpspec = G_PARAM_SPEC_LONG (pspec);
+
+      g_value_init (&self->priv->minimum_value, type);
+      g_value_set_long (&self->priv->minimum_value, tpspec->minimum);
+      g_value_init (&self->priv->maximum_value, type);
+      g_value_set_long (&self->priv->maximum_value, tpspec->maximum);
+      if (!G_IS_VALUE (&self->priv->amplitude)) {
+        g_value_init (&self->priv->amplitude, type);
+	g_value_set_long (&self->priv->amplitude, 0);
+      }
+
+      if (!G_IS_VALUE (&self->priv->offset)) {
+        g_value_init (&self->priv->offset, type);
+	g_value_set_long (&self->priv->offset, tpspec->default_value);
+      }
+      break;
+    }
+    case G_TYPE_ULONG:{
+      GParamSpecULong *tpspec = G_PARAM_SPEC_ULONG (pspec);
+
+      g_value_init (&self->priv->minimum_value, type);
+      g_value_set_ulong (&self->priv->minimum_value, tpspec->minimum);
+      g_value_init (&self->priv->maximum_value, type);
+      g_value_set_ulong (&self->priv->maximum_value, tpspec->maximum);
+      if (!G_IS_VALUE (&self->priv->amplitude)) {
+        g_value_init (&self->priv->amplitude, type);
+	g_value_set_ulong (&self->priv->amplitude, 0);
+      }
+
+      if (!G_IS_VALUE (&self->priv->offset)) {
+        g_value_init (&self->priv->offset, type);
+	g_value_set_ulong (&self->priv->offset, tpspec->default_value);
+      }
+      break;
+    }
+    case G_TYPE_INT64:{
+      GParamSpecInt64 *tpspec = G_PARAM_SPEC_INT64 (pspec);
+
+      g_value_init (&self->priv->minimum_value, type);
+      g_value_set_int64 (&self->priv->minimum_value, tpspec->minimum);
+      g_value_init (&self->priv->maximum_value, type);
+      g_value_set_int64 (&self->priv->maximum_value, tpspec->maximum);
+      if (!G_IS_VALUE (&self->priv->amplitude)) {
+        g_value_init (&self->priv->amplitude, type);
+	g_value_set_int64 (&self->priv->amplitude, 0);
+      }
+
+      if (!G_IS_VALUE (&self->priv->offset)) {
+        g_value_init (&self->priv->offset, type);
+	g_value_set_int64 (&self->priv->offset, tpspec->default_value);
+      }
+      break;
+    }
+    case G_TYPE_UINT64:{
+      GParamSpecUInt64 *tpspec = G_PARAM_SPEC_UINT64 (pspec);
+
+      g_value_init (&self->priv->minimum_value, type);
+      g_value_set_uint64 (&self->priv->minimum_value, tpspec->minimum);
+      g_value_init (&self->priv->maximum_value, type);
+      g_value_set_uint64 (&self->priv->maximum_value, tpspec->maximum);
+      if (!G_IS_VALUE (&self->priv->amplitude)) {
+        g_value_init (&self->priv->amplitude, type);
+	g_value_set_uint64 (&self->priv->amplitude, 0);
+      }
+
+      if (!G_IS_VALUE (&self->priv->offset)) {
+        g_value_init (&self->priv->offset, type);
+	g_value_set_uint64 (&self->priv->offset, tpspec->default_value);
+      }
+      break;
+    }
+    case G_TYPE_FLOAT:{
+      GParamSpecFloat *tpspec = G_PARAM_SPEC_FLOAT (pspec);
+
+      g_value_init (&self->priv->minimum_value, type);
+      g_value_set_float (&self->priv->minimum_value, tpspec->minimum);
+      g_value_init (&self->priv->maximum_value, type);
+      g_value_set_float (&self->priv->maximum_value, tpspec->maximum);
+      if (!G_IS_VALUE (&self->priv->amplitude)) {
+        g_value_init (&self->priv->amplitude, type);
+	g_value_set_float (&self->priv->amplitude, 0.0);
+      }
+
+      if (!G_IS_VALUE (&self->priv->offset)) {
+        g_value_init (&self->priv->offset, type);
+	g_value_set_float (&self->priv->offset, tpspec->default_value);
+      }
+      break;
+    }
+    case G_TYPE_DOUBLE:{
+      GParamSpecDouble *tpspec = G_PARAM_SPEC_DOUBLE (pspec);
+
+      g_value_init (&self->priv->minimum_value, type);
+      g_value_set_double (&self->priv->minimum_value, tpspec->minimum);
+      g_value_init (&self->priv->maximum_value, type);
+      g_value_set_double (&self->priv->maximum_value, tpspec->maximum);
+      if (!G_IS_VALUE (&self->priv->amplitude)) {
+        g_value_init (&self->priv->amplitude, type);
+	g_value_set_float (&self->priv->amplitude, 0.0);
+      }
+
+      if (!G_IS_VALUE (&self->priv->offset)) {
+        g_value_init (&self->priv->offset, type);
+	g_value_set_float (&self->priv->offset, tpspec->default_value);
+      }
+      break;
+    }
+    default:
+      GST_WARNING ("incomplete implementation for paramspec type '%s'",
+          G_PARAM_SPEC_TYPE_NAME (pspec));
+      ret = FALSE;
+      break;
+  }
+
+  if (ret) {
+    GValue amp = {0, }, off = {0, };
+
+    /* This should never fail unless the user already set amplitude or offset
+     * with an incompatible type before _bind () */
+    if (! g_value_type_transformable (G_VALUE_TYPE (&self->priv->amplitude), base) ||
+        ! g_value_type_transformable (G_VALUE_TYPE (&self->priv->offset), base)) {
+	GST_WARNING ("incompatible types for amplitude or offset");
+        gst_lfo_control_source_reset (self);
+        return FALSE;
+    }
+
+    /* Generate copies and transform to the correct type */
+    g_value_init (&amp, base);
+    g_value_transform (&self->priv->amplitude, &amp);
+    g_value_init (&off, base);
+    g_value_transform (&self->priv->offset, &off);
+
+    ret = gst_lfo_control_source_set_waveform (self,
+          self->priv->waveform, self->priv->frequency, self->priv->timeshift,
+	  &amp, &off);
+
+    g_value_unset (&amp);
+    g_value_unset (&off);
+  }
+
+  if (!ret)
+    gst_lfo_control_source_reset (self);
+
+  return ret;
+}
+
+static void
+gst_lfo_control_source_init (GstLFOControlSource * self)
+{
+  self->priv =
+      G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_LFO_CONTROL_SOURCE,
+      GstLFOControlSourcePrivate);
+  self->priv->waveform = GST_LFO_WAVEFORM_SINE;
+  self->priv->frequency = 1.0;
+  self->priv->period = GST_SECOND / self->priv->frequency;
+  self->priv->timeshift = 0;
+
+  self->lock = g_mutex_new ();
+}
+
+static void
+gst_lfo_control_source_finalize (GObject * obj)
+{
+  GstLFOControlSource *self = GST_LFO_CONTROL_SOURCE (obj);
+
+  gst_lfo_control_source_reset (self);
+
+  if (self->lock) {
+    g_mutex_free (self->lock);
+    self->lock = NULL;
+  }
+
+  G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+gst_lfo_control_source_dispose (GObject * obj)
+{
+  G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+static void
+gst_lfo_control_source_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstLFOControlSource *self = GST_LFO_CONTROL_SOURCE (object);
+
+  switch (prop_id) {
+    case PROP_WAVEFORM:
+      g_mutex_lock (self->lock);
+      gst_lfo_control_source_set_waveform_internal (self, g_value_get_enum (value));
+      g_mutex_unlock (self->lock);
+      break;
+    case PROP_FREQUENCY:{
+      gdouble frequency = g_value_get_double (value);
+
+      g_return_if_fail (frequency > 0 || ((GstClockTime) (GST_SECOND / frequency)) != 0);
+
+      g_mutex_lock (self->lock);
+      self->priv->frequency = frequency;
+      self->priv->period = GST_SECOND / frequency;
+      g_mutex_unlock (self->lock);
+      break;
+    }
+    case PROP_TIMESHIFT:
+      g_mutex_lock (self->lock);
+      self->priv->timeshift = g_value_get_uint64 (value);
+      g_mutex_unlock (self->lock);
+      break;
+    case PROP_AMPLITUDE:{
+      GValue *val = g_value_get_boxed (value);
+
+      if (self->priv->type != G_TYPE_INVALID) {
+        g_return_if_fail (g_value_type_transformable (self->priv->type, G_VALUE_TYPE (val)));
+
+        g_mutex_lock (self->lock);
+        if (G_IS_VALUE (&self->priv->amplitude))
+	  g_value_unset (&self->priv->amplitude);
+
+        g_value_init (&self->priv->amplitude, self->priv->type);
+	g_value_transform (val, &self->priv->amplitude);
+        g_mutex_unlock (self->lock);
+      } else {
+        g_mutex_lock (self->lock);
+        if (G_IS_VALUE (&self->priv->amplitude))
+	  g_value_unset (&self->priv->amplitude);
+
+	g_value_init (&self->priv->amplitude, G_VALUE_TYPE (val));
+	g_value_copy (val, &self->priv->amplitude);
+        g_mutex_unlock (self->lock);
+      }
+
+      break;
+    }
+    case PROP_OFFSET:{
+      GValue *val = g_value_get_boxed (value);
+
+      if (self->priv->type != G_TYPE_INVALID) {
+        g_return_if_fail (g_value_type_transformable (self->priv->type, G_VALUE_TYPE (val)));
+
+        g_mutex_lock (self->lock);
+        if (G_IS_VALUE (&self->priv->offset))
+	  g_value_unset (&self->priv->offset);
+
+        g_value_init (&self->priv->offset, self->priv->type);
+	g_value_transform (val, &self->priv->offset);
+        g_mutex_unlock (self->lock);
+      } else {
+        g_mutex_lock (self->lock);
+        if (G_IS_VALUE (&self->priv->offset))
+	  g_value_unset (&self->priv->offset);
+
+	g_value_init (&self->priv->offset, G_VALUE_TYPE (val));
+	g_value_copy (val, &self->priv->offset);
+        g_mutex_unlock (self->lock);
+      }
+
+      break;
+    }
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_lfo_control_source_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstLFOControlSource *self = GST_LFO_CONTROL_SOURCE (object);
+  
+  switch (prop_id) {
+    case PROP_WAVEFORM:
+      g_value_set_enum (value, self->priv->waveform);
+      break;
+    case PROP_FREQUENCY:
+      g_value_set_double (value, self->priv->frequency);
+      break;
+    case PROP_TIMESHIFT:
+      g_value_set_uint64 (value, self->priv->timeshift);
+      break;
+    case PROP_AMPLITUDE:
+      g_value_set_boxed (value, &self->priv->amplitude);
+      break;
+    case PROP_OFFSET:
+      g_value_set_boxed (value, &self->priv->offset);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+gst_lfo_control_source_class_init (GstLFOControlSourceClass
+    * klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GstControlSourceClass *csource_class = GST_CONTROL_SOURCE_CLASS (klass);
+
+  parent_class = g_type_class_peek_parent (klass);
+  g_type_class_add_private (klass,
+      sizeof (GstLFOControlSourcePrivate));
+
+  gobject_class->finalize = gst_lfo_control_source_finalize;
+  gobject_class->dispose = gst_lfo_control_source_dispose;
+  gobject_class->set_property = gst_lfo_control_source_set_property;
+  gobject_class->get_property = gst_lfo_control_source_get_property;
+
+  csource_class->bind = gst_lfo_control_source_bind;
+
+  /**
+   * GstLFOControlSource:waveform
+   *
+   * Specifies the waveform that should be used for this #GstLFOControlSource.
+   * 
+   **/
+  g_object_class_install_property (gobject_class, PROP_WAVEFORM,
+    g_param_spec_enum ("waveform", "Waveform", "Waveform",
+    GST_TYPE_LFO_WAVEFORM, GST_LFO_WAVEFORM_SINE,
+    G_PARAM_READWRITE));
+
+  /**
+   * GstLFOControlSource:frequency
+   *
+   * Specifies the frequency that should be used for the waveform
+   * of this #GstLFOControlSource. It should be large enough
+   * so that the period is longer than one nanosecond.
+   * 
+   **/
+  g_object_class_install_property (gobject_class, PROP_FREQUENCY,
+    g_param_spec_double ("frequency", "Frequency", "Frequency of the waveform",
+    0.0, G_MAXDOUBLE, 1.0, G_PARAM_READWRITE));
+
+  /**
+   * GstLFOControlSource:timeshift
+   *
+   * Specifies the timeshift to the right that should be used for the waveform
+   * of this #GstLFOControlSource in nanoseconds.
+   *
+   * To get a n nanosecond shift to the left use
+   * "(GST_SECOND / frequency) - n".
+   *
+   **/
+  g_object_class_install_property (gobject_class, PROP_TIMESHIFT,
+    g_param_spec_uint64 ("timeshift", "Timeshift", "Timeshift of the waveform to the right",
+    0, G_MAXUINT64, 0, G_PARAM_READWRITE));
+
+  /**
+   * GstLFOControlSource:amplitude
+   *
+   * Specifies the amplitude for the waveform of this #GstLFOControlSource.
+   *
+   * It should be given as a #GValue with a type that can be transformed
+   * to the type of the bound property.
+   **/
+  g_object_class_install_property (gobject_class, PROP_AMPLITUDE,
+    g_param_spec_boxed ("amplitude", "Amplitude", "Amplitude of the waveform",
+    G_TYPE_VALUE, G_PARAM_READWRITE));
+
+  /**
+   * GstLFOControlSource:offset
+   *
+   * Specifies the offset for the waveform of this #GstLFOControlSource.
+   *
+   * It should be given as a #GValue with a type that can be transformed
+   * to the type of the bound property.
+   **/
+  g_object_class_install_property (gobject_class, PROP_OFFSET,
+    g_param_spec_boxed ("offset", "Offset", "Offset of the waveform",
+    G_TYPE_VALUE, G_PARAM_READWRITE));
+}
+
Index: libs/gst/controller/gstlfocontrolsource.h
===================================================================
RCS file: libs/gst/controller/gstlfocontrolsource.h
diff -N libs/gst/controller/gstlfocontrolsource.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libs/gst/controller/gstlfocontrolsource.h	24 Jul 2007 03:37:43 -0000
@@ -0,0 +1,103 @@
+/* GStreamer
+ *
+ * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
+ *
+ * gstlfocontrolsource.h: Control source that provides some periodic waveforms
+ *                        as control values.
+ *
+ * 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_LFO_CONTROL_SOURCE_H__
+#define __GST_LFO_CONTROL_SOURCE_H__
+
+#include <glib-object.h>
+#include <gst/gst.h>
+
+#include "gstcontrolsource.h"
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_LFO_CONTROL_SOURCE \
+  (gst_lfo_control_source_get_type ())
+#define GST_LFO_CONTROL_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_LFO_CONTROL_SOURCE, GstLFOControlSource))
+#define GST_LFO_CONTROL_SOURCE_CLASS(vtable) \
+  (G_TYPE_CHECK_CLASS_CAST ((vtable), GST_TYPE_LFO_CONTROL_SOURCE, GstLFOControlSourceClass))
+#define GST_IS_LFO_CONTROL_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_LFO_CONTROL_SOURCE))
+#define GST_IS_LFO_CONTROL_SOURCE_CLASS(vtable) \
+  (G_TYPE_CHECK_CLASS_TYPE ((vtable), GST_TYPE_LFO_CONTROL_SOURCE))
+#define GST_LFO_CONTROL_SOURCE_GET_CLASS(inst) \
+  (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_LFO_CONTROL_SOURCE, GstLFOControlSourceClass))
+
+#define GST_TYPE_LFO_WAVEFORM (gst_lfo_waveform_get_type ())
+
+typedef struct _GstLFOControlSource GstLFOControlSource;
+typedef struct _GstLFOControlSourceClass GstLFOControlSourceClass;
+typedef struct _GstLFOControlSourcePrivate GstLFOControlSourcePrivate;
+
+/**
+ * GstLFOWaveForm:
+ * @GST_LFO_WAVEFORM_SINE: sine waveform
+ * @GST_LFO_WAVEFORM_SQUARE: square waveform
+ * @GST_LFO_WAVEFORM_SAW: saw waveform
+ * @GST_LFO_WAVEFORM_REVERSE_SAW: reverse saw waveform
+ * @GST_LFO_WAVEFORM_TRIANGLE: triangle waveform
+ *
+ * The various waveform modes available.
+ */
+typedef enum
+{
+  GST_LFO_WAVEFORM_SINE,
+  GST_LFO_WAVEFORM_SQUARE,
+  GST_LFO_WAVEFORM_SAW,
+  GST_LFO_WAVEFORM_REVERSE_SAW,
+  GST_LFO_WAVEFORM_TRIANGLE
+} GstLFOWaveform;
+
+/**
+ * GstLFOControlSource:
+ *
+ * The instance structure of #GstControlSource.
+ */
+struct _GstLFOControlSource {
+  GstControlSource parent;
+
+  /* <private> */
+  GstLFOControlSourcePrivate *priv;
+  GMutex *lock;
+  gpointer _gst_reserved[GST_PADDING];
+};
+
+struct _GstLFOControlSourceClass {
+  GstControlSourceClass parent_class;
+  
+  /*< private >*/
+  gpointer _gst_reserved[GST_PADDING];
+};
+
+GType gst_lfo_control_source_get_type ();
+GType gst_lfo_waveform_get_type ();
+
+/* Functions */
+
+GstLFOControlSource *gst_lfo_control_source_new ();
+gboolean gst_lfo_control_source_set_waveform (GstLFOControlSource *self, GstLFOWaveform waveform, gdouble frequency, GstClockTime timeshift, GValue *amplitude, GValue *offset);
+
+G_END_DECLS
+
+#endif /* __GST_LFO_CONTROL_SOURCE_H__ */
Index: libs/gst/controller/gstlfocontrolsourceprivate.h
===================================================================
RCS file: libs/gst/controller/gstlfocontrolsourceprivate.h
diff -N libs/gst/controller/gstlfocontrolsourceprivate.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libs/gst/controller/gstlfocontrolsourceprivate.h	24 Jul 2007 03:37:43 -0000
@@ -0,0 +1,64 @@
+/* GStreamer
+ *
+ * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
+ *
+ * gstlfocontrolsourceprivate.h: Private declarations for the
+ *                                         GstLFOControlSource
+ *
+ * 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_LFO_CONTROL_SOURCE_PRIVATE_H__
+#define __GST_LFO_CONTROL_SOURCE_PRIVATE_H__
+
+typedef struct _GstWaveformImplementation
+{
+  GstControlSourceGetValue get_int;
+  GstControlSourceGetValueArray get_int_value_array;
+  GstControlSourceGetValue get_uint;
+  GstControlSourceGetValueArray get_uint_value_array;
+  GstControlSourceGetValue get_long;
+  GstControlSourceGetValueArray get_long_value_array;
+  GstControlSourceGetValue get_ulong;
+  GstControlSourceGetValueArray get_ulong_value_array;
+  GstControlSourceGetValue get_int64;
+  GstControlSourceGetValueArray get_int64_value_array;
+  GstControlSourceGetValue get_uint64;
+  GstControlSourceGetValueArray get_uint64_value_array;
+  GstControlSourceGetValue get_float;
+  GstControlSourceGetValueArray get_float_value_array;
+  GstControlSourceGetValue get_double;
+  GstControlSourceGetValueArray get_double_value_array;
+} GstWaveformImplementation;
+
+struct _GstLFOControlSourcePrivate
+{
+  GType type;                   /* type of the handled property */
+  GType base;                   /* base-type of the handled property */
+
+  GValue minimum_value;         /* min value for the handled property */
+  GValue maximum_value;         /* max value for the handled property */
+
+  GstLFOWaveform waveform;
+  gdouble frequency;
+  GstClockTime period;
+  GstClockTime timeshift;
+  GValue amplitude;
+  GValue offset; 
+};
+
+#endif /* __GST_LFO_CONTROL_SOURCE_PRIVATE_H__ */
+
Index: tests/check/libs/controller.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/tests/check/libs/controller.c,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 controller.c
--- tests/check/libs/controller.c	6 Jul 2007 21:50:02 -0000	1.27
+++ tests/check/libs/controller.c	24 Jul 2007 03:37:46 -0000
@@ -3,7 +3,7 @@
  * unit test for the controller library
  *
  * Copyright (C) <2005> Stefan Kost <ensonic at users dot sf dot net>
- * Copyright (C) <2006> Sebastian Dröge <slomo@circular-chaos.org>
+ * Copyright (C) <2006-2007> Sebastian Dröge <slomo@circular-chaos.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -29,6 +29,7 @@
 #include <gst/controller/gstcontroller.h>
 #include <gst/controller/gstcontrolsource.h>
 #include <gst/controller/gstinterpolationcontrolsource.h>
+#include <gst/controller/gstlfocontrolsource.h>
 
 /* LOCAL TEST ELEMENT */
 
@@ -1419,6 +1420,535 @@ GST_START_TEST (controller_interpolation
 
 GST_END_TEST;
 
+/* test lfo control source with sine waveform */
+GST_START_TEST (controller_lfo_sine)
+{
+  GstController *ctrl;
+  GstLFOControlSource *csource;
+  GstElement *elem;
+  GValue amp = { 0, }, off = {0, };
+
+  gst_controller_init (NULL, NULL);
+
+  elem = gst_element_factory_make ("testmonosource", "test_source");
+
+  /* that property should exist and should be controllable */
+  ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
+  fail_unless (ctrl != NULL, NULL);
+
+  /* Get interpolation control source */
+  csource = gst_lfo_control_source_new ();
+
+  fail_unless (csource != NULL);
+  fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+          GST_CONTROL_SOURCE (csource)));
+
+  /* set amplitude and offset values */
+  g_value_init (&amp, G_TYPE_ULONG);
+  g_value_init (&off, G_TYPE_ULONG);
+  g_value_set_ulong (&amp, 100);
+  g_value_set_ulong (&off, 100);
+
+  /* set waveform mode */
+  fail_unless (gst_lfo_control_source_set_waveform (csource, GST_LFO_WAVEFORM_SINE, 1.0, 0, &amp, &off));
+
+  g_object_unref (G_OBJECT (csource));
+
+  /* now pull in values for some timestamps */
+  gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+
+  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
+  g_object_unref (ctrl);
+  gst_object_unref (elem);
+}
+
+GST_END_TEST;
+
+/* test lfo control source with sine waveform and timeshift */
+GST_START_TEST (controller_lfo_sine_timeshift)
+{
+  GstController *ctrl;
+  GstLFOControlSource *csource;
+  GstElement *elem;
+  GValue amp = { 0, }, off = {0, };
+
+  gst_controller_init (NULL, NULL);
+
+  elem = gst_element_factory_make ("testmonosource", "test_source");
+
+  /* that property should exist and should be controllable */
+  ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
+  fail_unless (ctrl != NULL, NULL);
+
+  /* Get interpolation control source */
+  csource = gst_lfo_control_source_new ();
+
+  fail_unless (csource != NULL);
+  fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+          GST_CONTROL_SOURCE (csource)));
+
+  /* set amplitude and offset values */
+  g_value_init (&amp, G_TYPE_ULONG);
+  g_value_init (&off, G_TYPE_ULONG);
+  g_value_set_ulong (&amp, 100);
+  g_value_set_ulong (&off, 100);
+
+  /* set waveform mode */
+  fail_unless (gst_lfo_control_source_set_waveform (csource, GST_LFO_WAVEFORM_SINE, 1.0, 250 * GST_MSECOND, &amp, &off));
+
+  g_object_unref (G_OBJECT (csource));
+
+/* now pull in values for some timestamps */
+  gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+
+  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
+  g_object_unref (ctrl);
+  gst_object_unref (elem);
+}
+
+GST_END_TEST;
+
+
+/* test lfo control source with square waveform */
+GST_START_TEST (controller_lfo_square)
+{
+  GstController *ctrl;
+  GstLFOControlSource *csource;
+  GstElement *elem;
+  GValue amp = { 0, }, off = {0, };
+
+  gst_controller_init (NULL, NULL);
+
+  elem = gst_element_factory_make ("testmonosource", "test_source");
+
+  /* that property should exist and should be controllable */
+  ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
+  fail_unless (ctrl != NULL, NULL);
+
+  /* Get interpolation control source */
+  csource = gst_lfo_control_source_new ();
+
+  fail_unless (csource != NULL);
+  fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+          GST_CONTROL_SOURCE (csource)));
+
+  /* set amplitude and offset values */
+  g_value_init (&amp, G_TYPE_ULONG);
+  g_value_init (&off, G_TYPE_ULONG);
+  g_value_set_ulong (&amp, 100);
+  g_value_set_ulong (&off, 100);
+
+  /* set waveform mode */
+  fail_unless (gst_lfo_control_source_set_waveform (csource, GST_LFO_WAVEFORM_SQUARE, 1.0, 0, &amp, &off));
+
+  g_object_unref (G_OBJECT (csource));
+
+  /* now pull in values for some timestamps */
+  gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+
+  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
+  g_object_unref (ctrl);
+  gst_object_unref (elem);
+}
+
+GST_END_TEST;
+
+/* test lfo control source with saw waveform */
+GST_START_TEST (controller_lfo_saw)
+{
+  GstController *ctrl;
+  GstLFOControlSource *csource;
+  GstElement *elem;
+  GValue amp = { 0, }, off = {0, };
+
+  gst_controller_init (NULL, NULL);
+
+  elem = gst_element_factory_make ("testmonosource", "test_source");
+
+  /* that property should exist and should be controllable */
+  ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
+  fail_unless (ctrl != NULL, NULL);
+
+  /* Get interpolation control source */
+  csource = gst_lfo_control_source_new ();
+
+  fail_unless (csource != NULL);
+  fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+          GST_CONTROL_SOURCE (csource)));
+
+  /* set amplitude and offset values */
+  g_value_init (&amp, G_TYPE_ULONG);
+  g_value_init (&off, G_TYPE_ULONG);
+  g_value_set_ulong (&amp, 100);
+  g_value_set_ulong (&off, 100);
+
+  /* set waveform mode */
+  fail_unless (gst_lfo_control_source_set_waveform (csource, GST_LFO_WAVEFORM_SAW, 1.0, 0, &amp, &off));
+
+  g_object_unref (G_OBJECT (csource));
+
+  /* now pull in values for some timestamps */
+  gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 150, NULL);
+  gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);
+  gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 150, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);
+  gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 150, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);
+
+  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
+  g_object_unref (ctrl);
+  gst_object_unref (elem);
+}
+
+GST_END_TEST;
+
+/* test lfo control source with reverse saw waveform */
+GST_START_TEST (controller_lfo_rsaw)
+{
+  GstController *ctrl;
+  GstLFOControlSource *csource;
+  GstElement *elem;
+  GValue amp = { 0, }, off = {0, };
+
+  gst_controller_init (NULL, NULL);
+
+  elem = gst_element_factory_make ("testmonosource", "test_source");
+
+  /* that property should exist and should be controllable */
+  ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
+  fail_unless (ctrl != NULL, NULL);
+
+  /* Get interpolation control source */
+  csource = gst_lfo_control_source_new ();
+
+  fail_unless (csource != NULL);
+  fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+          GST_CONTROL_SOURCE (csource)));
+
+  /* set amplitude and offset values */
+  g_value_init (&amp, G_TYPE_ULONG);
+  g_value_init (&off, G_TYPE_ULONG);
+  g_value_set_ulong (&amp, 100);
+  g_value_set_ulong (&off, 100);
+
+  /* set waveform mode */
+  fail_unless (gst_lfo_control_source_set_waveform (csource, GST_LFO_WAVEFORM_REVERSE_SAW, 1.0, 0, &amp, &off));
+
+  g_object_unref (G_OBJECT (csource));
+
+  /* now pull in values for some timestamps */
+  gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);
+  gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 150, NULL);
+  gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 150, NULL);
+  gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 150, NULL);
+
+  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
+  g_object_unref (ctrl);
+  gst_object_unref (elem);
+}
+
+GST_END_TEST;
+
+/* test lfo control source with saw waveform */
+GST_START_TEST (controller_lfo_triangle)
+{
+  GstController *ctrl;
+  GstLFOControlSource *csource;
+  GstElement *elem;
+  GValue amp = { 0, }, off = {0, };
+
+  gst_controller_init (NULL, NULL);
+
+  elem = gst_element_factory_make ("testmonosource", "test_source");
+
+  /* that property should exist and should be controllable */
+  ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
+  fail_unless (ctrl != NULL, NULL);
+
+  /* Get interpolation control source */
+  csource = gst_lfo_control_source_new ();
+
+  fail_unless (csource != NULL);
+  fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+          GST_CONTROL_SOURCE (csource)));
+
+  /* set amplitude and offset values */
+  g_value_init (&amp, G_TYPE_ULONG);
+  g_value_init (&off, G_TYPE_ULONG);
+  g_value_set_ulong (&amp, 100);
+  g_value_set_ulong (&off, 100);
+
+  /* set waveform mode */
+  fail_unless (gst_lfo_control_source_set_waveform (csource, GST_LFO_WAVEFORM_TRIANGLE, 1.0, 0, &amp, &off));
+
+  g_object_unref (G_OBJECT (csource));
+
+  /* now pull in values for some timestamps */
+  gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+
+  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
+  g_object_unref (ctrl);
+  gst_object_unref (elem);
+}
+
+GST_END_TEST;
+
+/* test lfo control source with square waveform */
+GST_START_TEST (controller_lfo_square_properties)
+{
+  GstController *ctrl;
+  GstLFOControlSource *csource;
+  GstElement *elem;
+  GValue amp = { 0, }, off = {0, };
+
+  gst_controller_init (NULL, NULL);
+
+  elem = gst_element_factory_make ("testmonosource", "test_source");
+
+  /* that property should exist and should be controllable */
+  ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
+  fail_unless (ctrl != NULL, NULL);
+
+  /* Get interpolation control source */
+  csource = gst_lfo_control_source_new ();
+
+  fail_unless (csource != NULL);
+  fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+          GST_CONTROL_SOURCE (csource)));
+
+  /* set amplitude and offset values */
+  g_value_init (&amp, G_TYPE_ULONG);
+  g_value_init (&off, G_TYPE_ULONG);
+  g_value_set_ulong (&amp, 100);
+  g_value_set_ulong (&off, 100);
+
+  /* set waveform mode via properties */
+  g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SQUARE,
+      "frequency", 1.0, "timeshift", (GstClockTime) 0,
+      "amplitude", &amp, "offset", &off, NULL);
+
+  g_object_unref (G_OBJECT (csource));
+
+  /* now pull in values for some timestamps */
+  gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 200, NULL);
+
+  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
+  g_object_unref (ctrl);
+  gst_object_unref (elem);
+}
+
+GST_END_TEST;
+
+/* test lfo control source with nothing set */
+GST_START_TEST (controller_lfo_none)
+{
+  GstController *ctrl;
+  GstLFOControlSource *csource;
+  GstElement *elem;
+
+  gst_controller_init (NULL, NULL);
+
+  elem = gst_element_factory_make ("testmonosource", "test_source");
+
+  /* that property should exist and should be controllable */
+  ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
+  fail_unless (ctrl != NULL, NULL);
+
+  /* Get interpolation control source */
+  csource = gst_lfo_control_source_new ();
+
+  fail_unless (csource != NULL);
+  fail_unless (gst_controller_set_control_source (ctrl, "ulong",
+          GST_CONTROL_SOURCE (csource)));
+
+  g_object_unref (G_OBJECT (csource));
+
+  /* now pull in values for some timestamps */
+  gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+  gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
+  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);
+
+  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
+  g_object_unref (ctrl);
+  gst_object_unref (elem);
+}
+
+GST_END_TEST;
+
 /* tests if we can run helper methods against any GObject */
 GST_START_TEST (controller_helper_any_gobject)
 {
@@ -1548,6 +2078,14 @@ gst_controller_suite (void)
   tcase_add_test (tc, controller_interpolation_linear_default_values);
   tcase_add_test (tc, controller_interpolate_linear_disabled);
   tcase_add_test (tc, controller_interpolation_set_from_list);
+  tcase_add_test (tc, controller_lfo_sine);
+  tcase_add_test (tc, controller_lfo_sine_timeshift);
+  tcase_add_test (tc, controller_lfo_square);
+  tcase_add_test (tc, controller_lfo_saw);
+  tcase_add_test (tc, controller_lfo_rsaw);
+  tcase_add_test (tc, controller_lfo_triangle);
+  tcase_add_test (tc, controller_lfo_square_properties);
+  tcase_add_test (tc, controller_lfo_none);
   tcase_add_test (tc, controller_helper_any_gobject);
 
   return s;
Index: docs/libs/gstreamer-libs-docs.sgml
===================================================================
RCS file: /cvs/gstreamer/gstreamer/docs/libs/gstreamer-libs-docs.sgml,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 gstreamer-libs-docs.sgml
--- docs/libs/gstreamer-libs-docs.sgml	6 Jul 2007 21:50:02 -0000	1.30
+++ docs/libs/gstreamer-libs-docs.sgml	24 Jul 2007 03:37:46 -0000
@@ -19,6 +19,7 @@
 <!ENTITY GstController SYSTEM "xml/gstcontroller.xml">
 <!ENTITY GstControlSource SYSTEM "xml/gstcontrolsource.xml">
 <!ENTITY GstInterpolationControlSource SYSTEM "xml/gstinterpolationcontrolsource.xml">
+<!ENTITY GstLFOControlSource SYSTEM "xml/gstlfocontrolsource.xml">
 <!ENTITY GstControllerGObject SYSTEM "xml/gstcontrollergobject.xml">
 <!ENTITY GstDataProtocol SYSTEM "xml/gstdataprotocol.xml">
 
@@ -70,6 +71,7 @@
       &GstController;
       &GstControlSource;
       &GstInterpolationControlSource;
+      &GstLFOControlSource;
       &GstControllerGObject;
     </chapter>
 
Index: docs/libs/gstreamer-libs-sections.txt
===================================================================
RCS file: /cvs/gstreamer/gstreamer/docs/libs/gstreamer-libs-sections.txt,v
retrieving revision 1.62
diff -u -p -u -p -r1.62 gstreamer-libs-sections.txt
--- docs/libs/gstreamer-libs-sections.txt	6 Jul 2007 21:50:02 -0000	1.62
+++ docs/libs/gstreamer-libs-sections.txt	24 Jul 2007 03:37:46 -0000
@@ -149,6 +149,29 @@ gst_interpolation_control_source_get_typ
 </SECTION>
 
 <SECTION>
+<FILE>gstlfocontrolsource</FILE>
+<TITLE>GstLFOControlSource</TITLE>
+<INCLUDE>libs/controller/gstlfocontrolsource.h</INCLUDE>
+GstLFOControlSource
+GstLFOWaveform
+gst_lfo_control_source_new
+gst_lfo_control_source_set_waveform
+<SUBSECTION Standard>
+GstLFOControlSourceClass
+GstLFOControlSourcePrivate
+GST_IS_LFO_CONTROL_SOURCE
+GST_IS_LFO_CONTROL_SOURCE_CLASS
+GST_LFO_CONTROL_SOURCE
+GST_LFO_CONTROL_SOURCE_CLASS
+GST_LFO_CONTROL_SOURCE_GET_CLASS
+GST_TYPE_LFO_CONTROL_SOURCE
+GST_TYPE_LFO_WAVEFORM
+<SUBSECTION Private>
+gst_lfo_control_source_get_type
+gst_lfo_waveform_get_type
+</SECTION>
+
+<SECTION>
 <FILE>gstcontrollergobject</FILE>
 <TITLE>GstControllerGObject</TITLE>
 <INCLUDE>libs/controller/gstcontroller.h</INCLUDE>
Index: docs/libs/gstreamer-libs.types
===================================================================
RCS file: /cvs/gstreamer/gstreamer/docs/libs/gstreamer-libs.types,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 gstreamer-libs.types
--- docs/libs/gstreamer-libs.types	6 Jul 2007 21:50:02 -0000	1.7
+++ docs/libs/gstreamer-libs.types	24 Jul 2007 03:37:46 -0000
@@ -6,6 +6,9 @@ gst_controller_get_type
 gst_control_source_get_type
 #include <gst/controller/gstinterpolationcontrolsource.h>
 gst_interpolation_control_source_get_type
+#include <gst/controller/gstlfocontrolsource.h>
+gst_lfo_control_source_get_type
+gst_lfo_waveform_get_type
 
 #include <gst/base/gstadapter.h>
 gst_adapter_get_type
