4 * Builds a pipeline with audiotestsource->alsasink and sweeps frequency and
7 * Needs gst-plugin-base installed.
11 #include <gst/controller/gstcontroller.h>
12 #include <gst/controller/gstinterpolationcontrolsource.h>
15 main (gint argc, gchar ** argv)
18 GstElement *src, *sink;
21 GstInterpolationControlSource *csource1, *csource2;
24 GstClockReturn wait_ret;
27 gst_init (&argc, &argv);
28 gst_controller_init (&argc, &argv);
31 bin = gst_pipeline_new ("pipeline");
32 clock = gst_pipeline_get_clock (GST_PIPELINE (bin));
33 src = gst_element_factory_make ("audiotestsrc", "gen_audio");
35 GST_WARNING ("need audiotestsrc from gst-plugins-base");
38 sink = gst_element_factory_make ("autoaudiosink", "play_audio");
40 GST_WARNING ("need autoaudiosink from gst-plugins-base");
44 gst_bin_add_many (GST_BIN (bin), src, sink, NULL);
45 if (!gst_element_link (src, sink)) {
46 GST_WARNING ("can't link elements");
51 g_object_set (G_OBJECT(src), "wave", 1, NULL);
54 /* add a controller to the source */
55 if (!(ctrl = gst_controller_new (G_OBJECT (src), "freq", "volume", NULL))) {
56 GST_WARNING ("can't control source element");
60 csource1 = gst_interpolation_control_source_new ();
61 csource2 = gst_interpolation_control_source_new ();
63 gst_controller_set_control_source (ctrl, "volume",
64 GST_CONTROL_SOURCE (csource1));
65 gst_controller_set_control_source (ctrl, "freq",
66 GST_CONTROL_SOURCE (csource2));
68 /* Set interpolation mode */
70 gst_interpolation_control_source_set_interpolation_mode (csource1,
71 GST_INTERPOLATE_LINEAR);
72 gst_interpolation_control_source_set_interpolation_mode (csource2,
73 GST_INTERPOLATE_LINEAR);
75 /* set control values */
76 g_value_init (&vol, G_TYPE_DOUBLE);
77 g_value_set_double (&vol, 0.0);
78 gst_interpolation_control_source_set (csource1, 0 * GST_SECOND, &vol);
79 g_value_set_double (&vol, 1.0);
80 gst_interpolation_control_source_set (csource1, 5 * GST_SECOND, &vol);
82 g_object_unref (csource1);
84 g_value_set_double (&vol, 220.0);
85 gst_interpolation_control_source_set (csource2, 0 * GST_SECOND, &vol);
86 g_value_set_double (&vol, 3520.0);
87 gst_interpolation_control_source_set (csource2, 3 * GST_SECOND, &vol);
88 g_value_set_double (&vol, 440.0);
89 gst_interpolation_control_source_set (csource2, 6 * GST_SECOND, &vol);
91 g_object_unref (csource2);
94 gst_clock_new_single_shot_id (clock,
95 gst_clock_get_time (clock) + (7 * GST_SECOND));
97 /* run for 7 seconds */
98 if (gst_element_set_state (bin, GST_STATE_PLAYING)) {
99 if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) {
100 GST_WARNING ("clock_id_wait returned: %d", wait_ret);
102 gst_element_set_state (bin, GST_STATE_NULL);
106 g_object_unref (G_OBJECT (ctrl));
107 gst_clock_id_unref (clock_id);
108 gst_object_unref (G_OBJECT (clock));
109 gst_object_unref (G_OBJECT (bin));