2005-09-29 15:42:31 +00:00
|
|
|
#!/usr/bin/env python
|
2005-11-19 10:37:58 +00:00
|
|
|
# -*- Mode: Python -*-
|
|
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
2005-09-29 15:42:31 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2006-05-27 12:08:08 +00:00
|
|
|
import pygst
|
|
|
|
pygst.require('0.10')
|
2005-09-29 15:42:31 +00:00
|
|
|
import gst
|
|
|
|
import time
|
|
|
|
|
|
|
|
def main():
|
|
|
|
pipeline = gst.Pipeline("audiocontroller")
|
2006-05-27 12:08:08 +00:00
|
|
|
src = gst.element_factory_make("audiotestsrc", "src")
|
2005-09-29 15:42:31 +00:00
|
|
|
sink = gst.element_factory_make("alsasink", "sink")
|
2006-05-27 12:08:08 +00:00
|
|
|
pipeline.add(src, sink)
|
2005-09-29 15:42:31 +00:00
|
|
|
src.link(sink)
|
|
|
|
|
|
|
|
control = gst.Controller(src, "freq", "volume")
|
|
|
|
control.set_interpolation_mode("volume", gst.INTERPOLATE_LINEAR)
|
2006-11-22 17:31:02 +00:00
|
|
|
control.set_interpolation_mode("freq", gst.INTERPOLATE_LINEAR)
|
2005-09-29 15:42:31 +00:00
|
|
|
|
|
|
|
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()
|