home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / python-gst0.10 / examples / audio-controller.py next >
Encoding:
Python Source  |  2006-07-31  |  1.1 KB  |  41 lines

  1. #!/usr/bin/env python
  2. # -*- Mode: Python -*-
  3. # vi:si:et:sw=4:sts=4:ts=4
  4.  
  5. # audio-controller.py
  6. # (c) 2005 Edward Hervey <edward at fluendo dot com>
  7. # Test case for the GstController on sinesrc -> alsasink
  8. # Inspired from ensonic's examples/controller/audio-controller.c
  9.  
  10. import pygst
  11. pygst.require('0.10')
  12. import gst
  13. import time
  14.  
  15. def main():
  16.     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.     src.link(sink)
  21.  
  22.     control = gst.Controller(src, "freq", "volume")
  23.     control.set_interpolation_mode("volume", gst.INTERPOLATE_LINEAR)
  24.     control.set_interpolation_mode("volume", gst.INTERPOLATE_LINEAR)
  25.  
  26.     control.set("volume", 0, 0.0)
  27.     control.set("volume", 2 * gst.SECOND, 1.0)
  28.     control.set("volume", 4 * gst.SECOND, 0.0)
  29.     control.set("volume", 6 * gst.SECOND, 1.0)
  30.  
  31.     control.set("freq", 0, 440.0)
  32.     control.set("freq", 3 * gst.SECOND, 3000.0)
  33.     control.set("freq", 6 * gst.SECOND, 880.0)
  34.  
  35.     pipeline.set_state(gst.STATE_PLAYING)
  36.  
  37.     time.sleep(7)
  38.  
  39. if __name__ == "__main__":
  40.     main()
  41.