def __init__(self, config, logger): self.patch = 'masterPatch.pd' self.config = config self.log = logger comPort = self.config.getint('puredata', 'comPort') self.fadeTime = self.config.getint('puredata', 'fadeTime') self.playTime = self.config.getint('puredata', 'playTime') gui = False self.regWait = False self.pdnum = 0 self.regTimeout = 20 self.connection = False extras = "-alsa" self.masterDir = self.config.get('paths', 'masterDir') path = [self.masterDir] Pd.__init__(self, comPort, gui, self.patch, extra=extras, path=path) self.log.write("Starting PD Process:%s" % self.argLine)
from time import time, sleep from os import path, getcwd from Pd import Pd start = time() # launching pd pd = Pd(nogui=False) pd.Send(["test message", 1, 2, 3]) def Pd_hello(self, message): print "Pd called Pd_hello(%s)" % message pd.Pd_hello = Pd_hello sentexit = False # running a bunch of stuff for up to 20 seconds while time() - start < 60 and pd.Alive(): if time() - start > 20 and not sentexit: pd.Send(["exit"]) sentexit = True pd.Update() if pd.Alive(): pd.Exit()