4 * Builds a pipeline with [ audiotestsource ! autoaudiosink ] and sweeps
5 * frequency and volume.
7 * Needs gst-plugin-base + gst-plugins-good installed.
11 #include <gst/controller/gstinterpolationcontrolsource.h>
14 main (gint argc, gchar ** argv)
17 GstElement *src, *sink;
19 GstInterpolationControlSource *csource1, *csource2;
20 GstTimedValueControlSource *cs;
23 GstClockReturn wait_ret;
25 gst_init (&argc, &argv);
28 bin = gst_pipeline_new ("pipeline");
29 clock = gst_pipeline_get_clock (GST_PIPELINE (bin));
30 src = gst_element_factory_make ("audiotestsrc", NULL);
32 GST_WARNING ("need audiotestsrc from gst-plugins-base");
35 sink = gst_element_factory_make ("autoaudiosink", NULL);
37 GST_WARNING ("need autoaudiosink from gst-plugins-good");
41 gst_bin_add_many (GST_BIN (bin), src, sink, NULL);
42 if (!gst_element_link (src, sink)) {
43 GST_WARNING ("can't link elements");
47 /* setup control sources */
48 csource1 = gst_interpolation_control_source_new ();
49 csource2 = gst_interpolation_control_source_new ();
51 gst_object_set_control_binding (GST_OBJECT_CAST (src),
52 gst_control_binding_new (GST_OBJECT_CAST (src), "volume",
53 GST_CONTROL_SOURCE (csource1)));
54 gst_object_set_control_binding (GST_OBJECT_CAST (src),
55 gst_control_binding_new (GST_OBJECT_CAST (src), "freq",
56 GST_CONTROL_SOURCE (csource2)));
58 /* set interpolation mode */
60 g_object_set (csource1, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
61 g_object_set (csource2, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
63 /* set control values */
64 cs = (GstTimedValueControlSource *) csource1;
65 gst_timed_value_control_source_set (cs, 0 * GST_SECOND, 0.0);
66 gst_timed_value_control_source_set (cs, 5 * GST_SECOND, 1.0);
68 gst_object_unref (csource1);
70 cs = (GstTimedValueControlSource *) csource2;
71 gst_timed_value_control_source_set (cs, 0 * GST_SECOND, 220.0 / 20000.0);
72 gst_timed_value_control_source_set (cs, 3 * GST_SECOND, 3520.0 / 20000.0);
73 gst_timed_value_control_source_set (cs, 6 * GST_SECOND, 440.0 / 20000.0);
75 gst_object_unref (csource2);
77 /* run for 7 seconds */
79 gst_clock_new_single_shot_id (clock,
80 gst_clock_get_time (clock) + (7 * GST_SECOND));
82 if (gst_element_set_state (bin, GST_STATE_PLAYING)) {
83 if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) {
84 GST_WARNING ("clock_id_wait returned: %d", wait_ret);
86 gst_element_set_state (bin, GST_STATE_NULL);
90 gst_clock_id_unref (clock_id);
91 gst_object_unref (G_OBJECT (clock));
92 gst_object_unref (G_OBJECT (bin));