Thanks again, I don't know anything about Python programming but where would I label the inputs for the frequency and the volume at? I can easily make the changes to the frequency, a dog whistle is anywhere from 16000 to 22000 Hz and for the volume anything over 0.1 is to loud the speakers on the FreeRunner struggle with it, what I mean by that is 22000 Hz sounds lower than 17000 Hz.<br>
<br><div class="gmail_quote">On Fri, Apr 24, 2009 at 11:20 AM, Stuart Pullinger <span dir="ltr"><<a href="mailto:s.pullinger@elec.gla.ac.uk">s.pullinger@elec.gla.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Adam Jimerson wrote:<br>
> Thanks that is what I was looking for,<br>
</div>No probs.<br>
<div class="im"><br>
> to bad there isn't a UI or anything for it.<br>
><br>
</div>Tadaaa! Hope pasting it into an email doesn't ruin the formatting. This<br>
is my first pygtk/pygst program and it has been cobbled together from<br>
various code examples on the web. I hope you like it.<br>
<br>
Stuart<br>
<br>
#!/usr/bin/env python<br>
<br>
##<br>
# testtone.py<br>
# Hacked together by Stuart Pullinger (s dot pullinger at elec dot gla<br>
dot ac dot uk) from the following sources:<br>
# <a href="http://www.pygtk.org/pygtk2tutorial/index.html" target="_blank">http://www.pygtk.org/pygtk2tutorial/index.html</a><br>
# <a href="http://pygstdocs.berlios.de/pygst-tutorial/index.html" target="_blank">http://pygstdocs.berlios.de/pygst-tutorial/index.html</a><br>
#<br>
<a href="http://www.jonobacon.org/2006/08/28/getting-started-with-gstreamer-with-python/" target="_blank">http://www.jonobacon.org/2006/08/28/getting-started-with-gstreamer-with-python/</a><br>
##<br>
<br>
import pygtk<br>
pygtk.require('2.0')<br>
import gtk<br>
import pygst<br>
pygst.require("0.10")<br>
import gst<br>
<br>
class TestTone:<br>
<br>
def startstop(self, widget, data=None):<br>
if self.playing:<br>
#we are playing so stop<br>
self.pipeline.set_state(gst.STATE_NULL)<br>
self.playing = False<br>
else:<br>
#we are stopped so start playing<br>
self.pipeline.set_state(gst.STATE_PLAYING)<br>
self.playing = True<br>
<br>
def change_freq(self, adj):<br>
self.audiotestsrc.set_property('freq', adj.value)<br>
<br>
def change_vol(self, adj):<br>
self.audiotestsrc.set_property('volume', adj.value)<br>
<br>
def delete_event(self, widget, event, data=None):<br>
print "delete event occurred"<br>
return False<br>
<br>
def destroy(self, widget, data=None):<br>
print "destroy signal occurred"<br>
gtk.main_quit()<br>
<br>
def __init__(self):<br>
# create a new window<br>
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)<br>
<br>
self.window.connect("delete_event", self.delete_event)<br>
self.window.connect("destroy", self.destroy)<br>
<br>
self.window.set_border_width(10)<br>
<br>
self.button = gtk.Button("Start / Stop")<br>
self.button.connect("clicked", self.startstop, None)<br>
<br>
self.adjustfreq = gtk.Adjustment(440, 20, 20000, 10, 100, 0)<br>
<br>
self.freq_button = gtk.SpinButton(adjustment=self.adjustfreq,<br>
climb_rate=0.5, digits=2)<br>
self.adjustfreq.connect('value_changed', self.change_freq)<br>
<br>
self.adjustvol = gtk.Adjustment(0.4, 0, 1, 0.01, 0.1, 0)<br>
self.vol_button = gtk.SpinButton(adjustment=self.adjustvol,<br>
climb_rate=0.5, digits=2)<br>
self.adjustvol.connect('value_changed', self.change_vol)<br>
<br>
self.pipeline = gst.Pipeline("mypipeline")<br>
self.audiotestsrc = gst.element_factory_make("audiotestsrc",<br>
"audio")<br>
self.audiotestsrc.set_property('freq', 440)<br>
self.audiotestsrc.set_property('volume', 0.4)<br>
self.pipeline.add(self.audiotestsrc)<br>
self.sink = gst.element_factory_make("alsasink", "sink")<br>
self.pipeline.add(self.sink)<br>
self.audiotestsrc.link(self.sink)<br>
<br>
self.playing = False<br>
<br>
self.vbox = gtk.VBox(False, 0)<br>
self.vbox.pack_start(self.freq_button)<br>
self.vbox.pack_start(self.vol_button)<br>
self.vbox.pack_start(self.button)<br>
self.window.add(self.vbox)<br>
self.button.show()<br>
self.freq_button.show()<br>
self.vol_button.show()<br>
self.vbox.show()<br>
self.window.show()<br>
<br>
def main(self):<br>
# All PyGTK applications must have a gtk.main(). Control ends here<br>
# and waits for an event to occur (like a key press or mouse event).<br>
gtk.main()<br>
<br>
# If the program is run directly or passed as an argument to the python<br>
# interpreter then create a HelloWorld instance and show it<br>
if __name__ == "__main__":<br>
testtone = TestTone()<br>
testtone.main()<br>
<div><div></div><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
Openmoko community mailing list<br>
<a href="mailto:community@lists.openmoko.org">community@lists.openmoko.org</a><br>
<a href="http://lists.openmoko.org/mailman/listinfo/community" target="_blank">http://lists.openmoko.org/mailman/listinfo/community</a><br>
</div></div></blockquote></div><br>