pyprocessing and pyo: need to call some shutdown functions on quit of window how to? exit callback?

35 views
Skip to first unread message

lucas p

unread,
Dec 1, 2012, 5:48:38 PM12/1/12
to pyprocess...@googlegroups.com
Hi all, I'm just getting started with pyprocessing and I want to use it with pyo a audio synthesis environment for python developed here at university de montreal. 
Things have been working great for now, I have an audiovisual "hello world" working drawing a line and playing a sine wave acording to pitch.
But the problem is when I quit the python window of my sketch: it gets stuck because I need to call some function on the audio server (s.stop, s.shutdown) before stopping the program.

SO I'm looking for some sort of callback, a way to define a function that gets executed when I'm quitting the app to shutdown the audio server. Is there an equivalent to the setup function for quitting? I tried defining an exit function but that doesn't seem to work.
Maybe this is something that isn't handle by pyprocessing but by pyglet or even python?

any help apreciated, here is what my script currently looks like:



from pyprocessing import *
from pyo import *

s = Server().boot()
freq = Sig(mouse.x*10)
a = Sine(freq).out()

def setup():
size(200,200)
stroke(255)
s.start()

def draw():
background(0)
line(mouse.x,mouse.y,150,100)
freq.setValue(mouse.x*10)
print mouse.x

run()
s.stop()
s.shutdown()

Reply all
Reply to author
Forward
0 new messages