audio-controller.py 1.12 KB
Newer Older
1
#!/usr/bin/env python
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
2 3
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
4 5 6 7 8 9

# audio-controller.py
# (c) 2005 Edward Hervey <edward at fluendo dot com>
# Test case for the GstController on sinesrc -> alsasink
# Inspired from ensonic's examples/controller/audio-controller.c

10 11
import pygst
pygst.require('0.10')
12 13 14 15 16
import gst
import time

def main():
    pipeline = gst.Pipeline("audiocontroller")
17
    src = gst.element_factory_make("audiotestsrc", "src")
18
    sink = gst.element_factory_make("alsasink", "sink")
19
    pipeline.add(src, sink)
20 21 22 23
    src.link(sink)

    control = gst.Controller(src, "freq", "volume")
    control.set_interpolation_mode("volume", gst.INTERPOLATE_LINEAR)
24
    control.set_interpolation_mode("freq", gst.INTERPOLATE_LINEAR)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

    control.set("volume", 0, 0.0)
    control.set("volume", 2 * gst.SECOND, 1.0)
    control.set("volume", 4 * gst.SECOND, 0.0)
    control.set("volume", 6 * gst.SECOND, 1.0)

    control.set("freq", 0, 440.0)
    control.set("freq", 3 * gst.SECOND, 3000.0)
    control.set("freq", 6 * gst.SECOND, 880.0)

    pipeline.set_state(gst.STATE_PLAYING)

    time.sleep(7)

if __name__ == "__main__":
    main()