PythonGStreamer: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
Line 27: Line 27:
</source>
</source>


== A command-line level analyzer ==
== Other Examples ==


[[Level.py]]
* [[Level.py | Level analyzer]]
 
* [[Spectrum.py | Spectral analysis]]
== A command-line spectrum analyzer ==
 
[[Spectrum.py]]
 
== Other Examples ==
* [[ListeningAndWatching]]
* [[ListeningAndWatching]]

Latest revision as of 12: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))

Other Examples