4 * Build a pipeline with testaudiosource->alsasink
5 * and sweep frequency and volume
10 #include <gst/controller/gst-controller.h>
13 main (gint argc, gchar ** argv)
16 GstElement *src, *sink;
21 GstClockReturn wait_ret;
24 gst_init (&argc, &argv);
25 gst_controller_init (&argc, &argv);
28 bin = gst_pipeline_new ("pipeline");
29 clock = gst_pipeline_get_clock (GST_PIPELINE (bin));
30 /* TODO make this "testaudiosrc", when its ready */
31 src = gst_element_factory_make ("sinesrc", "gen_audio");
32 sink = gst_element_factory_make ("alsasink", "play_audio");
33 gst_bin_add_many (GST_BIN (bin), src, sink, NULL);
34 if (!gst_element_link (src, sink)) {
35 GST_WARNING ("can't link elements");
38 // add a controller to the source
39 if (!(ctrl = gst_controller_new (G_OBJECT (src), "freq", "volume", NULL))) {
40 GST_WARNING ("can't control source element");
44 gst_controller_set_interpolation_mode (ctrl, "volume",
45 GST_INTERPOLATE_LINEAR);
46 gst_controller_set_interpolation_mode (ctrl, "freq", GST_INTERPOLATE_LINEAR);
49 g_value_init (&vol, G_TYPE_DOUBLE);
50 g_value_set_double (&vol, 0.0);
51 gst_controller_set (ctrl, "volume", 0 * GST_SECOND, &vol);
52 g_value_set_double (&vol, 1.0);
53 gst_controller_set (ctrl, "volume", 5 * GST_SECOND, &vol);
54 g_value_set_double (&vol, 440.0);
55 gst_controller_set (ctrl, "freq", 0 * GST_SECOND, &vol);
56 g_value_set_double (&vol, 3520.0);
57 gst_controller_set (ctrl, "freq", 3 * GST_SECOND, &vol);
58 g_value_set_double (&vol, 880.0);
59 gst_controller_set (ctrl, "freq", 6 * GST_SECOND, &vol);
62 gst_clock_new_single_shot_id (clock,
63 gst_clock_get_time (clock) + (7 * GST_SECOND));
66 if (gst_element_set_state (bin, GST_STATE_PLAYING)) {
67 if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) {
68 GST_WARNING ("clock_id_wait returned: %d", wait_ret);
70 gst_element_set_state (bin, GST_STATE_NULL);
73 g_object_unref (G_OBJECT (ctrl));
74 g_object_unref (G_OBJECT (clock));
75 g_object_unref (G_OBJECT (bin));