PythonGStreamer: Difference between revisions
No edit summary |
|||
Line 27: | Line 27: | ||
</source> | </source> | ||
== | == Other Examples == | ||
[[Level.py]] | * [[Level.py | Level analyzer]] | ||
* [[Spectrum.py | Spectral analysis]] | |||
[[Spectrum.py]] | |||
* [[ListeningAndWatching]] | * [[ListeningAndWatching]] |
Latest revision as of 11:41, 1 June 2009
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))