[PD] Using py/pyext to call Wavesurfer: Problems to get access to dsp

Jeannette Bohg bohg.jeannette at googlemail.com
Sun Feb 11 22:10:28 CET 2007


Hello,
I wrote the following simple python script to be used by pd with the
py/pyext external. It demonstrates a simple tcl/tk dialogue with the
wavesurfer application.

try:
	import pyext
except:
	print "ERROR: This script must be loaded by the PD/Max pyext external"

from Tkinter import *
from Wsurf import *
import random


class Application(Frame):
    """This is the TK application class"""

    def load(self):
        file = root.tk.eval('snack::getOpenFile')
        ws.openFile(file)

    # Some random commands
    def stuff(self):
        ws.xscroll('moveto',0.01)
        ws.configure(selection='1.00 3.00')
        ws.configure(title='Test')
        ws.play(1.00,3.00)
        print ws.cget('selection')

    # Create interface stuff
    def createWidgets(self):
        self.opFile = Button(self, image='snackOpen',
command=self.load )
        self.opFile.pack(side='left')
        self.ran = Button(self, text='Foo', command=self.stuff )
        self.ran.pack(side='left')

    # Constructor
    def __init__(self,cl):
        print 'init called'
        self.extcl = cl
        Frame.__init__(self)
        self.pack(pady=5)
        self.createWidgets()
        pass


# derive class from pyext._class

class myapp(pyext._class):
    """This class demonstrates how a TCL/TK can be openened from
within a pyext external"""

    # how many inlets and outlets?
    _inlets = 1
    _outlets = 1

    # Constructor
    def __init__(self):
	# detach bang method
        self._detach(1)

    def bang_1(self):
        self._priority(-3)
        # display the tcl/tk dialog
        global root
        root=Tk()
        root.tk.eval('package require -exact wsurf 1.8')
        global ws
        ws=Wsurf(root,title='ABC',configuration='')
        ws.pack(expand='yes',fill='both')
        f0 = Application(self)
        f0.mainloop()


I can load sound files into the wavesurfer application which also has
the functionality to play this file or to record sound input from a
microphone. The only problem is that WaveSurfer can not gain access to
dsp for writing or reading. Obviously because it is locked by PD.

Does any one see a possibility to, e.g., root the output of the
wavesurfer application through PD or some other solution?

Thanks, Jeannette.




More information about the Pd-list mailing list