PythonGStreamer
Revision as of 11:41, 1 June 2009 by Michael Murtaugh (talk | contribs)
Using Python to program GStreamer
Generating random tones
A python random oscillator stream:
import pygst
pygst.require("0.10")
import gst
pipeline = gst.Pipeline("mypipeline")
audiotestsrc = gst.element_factory_make("audiotestsrc", "audio")
pipeline.add(audiotestsrc)
sink = gst.element_factory_make("alsasink", "sink")
pipeline.add(sink)
audiotestsrc.link(sink)
audiotestsrc.set_property("freq", 800)
pipeline.set_state(gst.STATE_PLAYING)
import time, random
while 1:
f = random.randint(200, 800)
print "setting freq to: %d" % f
audiotestsrc.set_property("freq", f)
time.sleep(1.0/random.randint(1, 10))