PureData py/pyExt into standalone python

R

responsible7

Hi guys,

Short version:

I've written some python classes for py/pyExt extensions for the
"dataflow" graphical programming environment PureData. Here's an
example PureData screenshot for clarity:

see: http://i40.tinypic.com/2rrx6gy.jpg

My classes talk to eachother via the PureData system, and they talk to
the outside world via pyPortMIDI (which enables raw MIDI data
communication).

PureData encourages modularisation, so I've written several classes:
* some that receive raw MIDI data,
* some that parse this into human-readable tokens,
* some that just generate human-readable tokens,
* and some that parse human-readable tokens then send raw MIDI data

I want to join these together as a stand-alone python application,
using internal python communication instead of PureData...

....but I don't know how to do this. The only python I know comes from
writing using the pyExt API, and the PureData API (which is written in
C).

----
Long(er) version:

Miller Pukette's PureData: http://puredata.info/
Thomas Grill's Flext: http://puredata.info/Members/thomas/flext
Thomas Grill's Py/Pyext: http://puredata.info/Members/thomas/py/
John Harrison's PyPortMIDI: http://www.media.mit.edu/~harrison/code.html
CMU's PortMIDI: http://www.cs.cmu.edu/~music/portmusic/

PureData is a graphical "dataflow" programming environment that (among
many, many other things!) allows for very rapid development of Audio
and MIDI processing. Objects in PureData (and MaxMSP) communicate by
sending messages through "patch cords" that connect an "outlet" to an
"inlet" of another object.

Thomas Grill's py/pyExt allows python code to be embedded as a
PureData object. The benefit being that this python code can be
effortlessly ported across multiple platforms (win32/linux/osx) and
also to the highly related (but more commercial) Cycling'74 MaxMSP
system. (PureData object code is written in C and generally not easy
to port between platforms, nor between PD and MaxMSP - so writing
portable python objects is a boon!)

a pyExt object sends messages from its outlets using the line:


self._outlet(outlet_id,message_to_send)


a pyExt object performs actions when a message arrives at an inlet. An
integer arriving at inlet 1 could be attached to this method code:


def int_1(self,*arg):
print "received integer:",arg[0]

If these pieces of code were in separate python classes - how would I
connect two objects together such that an integer was passed between
the two?

If the first object sent 42, in puredata it would look like this:

http://i44.tinypic.com/15eh74p.gif

useless fact: the screenshot doubles up (i.e. "pyext sender sender")
due to the first word being the python file (i.e. sender.py), whilst
the second is the name of the object class (i.e class sender
(pyext._class)

----
Maybe a more tricky question is:

PureData supports "message busses" - messages sent to named busses can
be broadcast to multiple locations. How would I connect objects up in
this way using python?

a pyExt object registers to receive messages on a certain bus using:


self._bind(bus_name,self.method_to_call)

def method_to_call(self,*arg):
print "a message on", bus_name, "arrived"
print "the message was", len(arg), "long"
print "and had the values", arg, "inside"


a pyExt object sends messages to a particular bus by using:


self._send(bus_name,message_to_send)
 
E

edexter

Hi guys,

Short version:

I've written some python classes for py/pyExt extensions for the
"dataflow" graphical programming environment PureData. Here's an
example PureData screenshot for clarity:

        see:http://i40.tinypic.com/2rrx6gy.jpg

My classes talk to eachother via the PureData system, and they talk to
the outside world via pyPortMIDI (which enables raw MIDI data
communication).

PureData encourages modularisation, so I've written several classes:
* some that receive raw MIDI data,
* some that parse this into human-readable tokens,
* some that just generate human-readable tokens,
* and some that parse human-readable tokens then send raw MIDI data

I want to join these together as a stand-alone python application,
using internal python communication instead of PureData...

...but I don't know how to do this. The only python I know comes from
writing using the pyExt API, and the PureData API (which is written in
C).

----
Long(er) version:

Miller Pukette's PureData:http://puredata.info/
Thomas Grill's Flext:http://puredata.info/Members/thomas/flext
Thomas Grill's Py/Pyext:http://puredata.info/Members/thomas/py/
John Harrison's PyPortMIDI:http://www.media.mit.edu/~harrison/code.html
CMU's PortMIDI:http://www.cs.cmu.edu/~music/portmusic/

PureData is a graphical "dataflow" programming environment that (among
many, many other things!) allows for very rapid development of Audio
and MIDI processing. Objects in PureData (and MaxMSP) communicate by
sending messages through "patch cords" that connect an "outlet" to an
"inlet" of another object.

Thomas Grill's py/pyExt allows python code to be embedded as a
PureData object. The benefit being that this python code can be
effortlessly ported across multiple platforms (win32/linux/osx) and
also to the highly related (but more commercial) Cycling'74 MaxMSP
system. (PureData object code is written in C and generally not easy
to port between platforms, nor between PD and MaxMSP - so writing
portable python objects is a boon!)

a pyExt object sends messages from its outlets using the line:

        self._outlet(outlet_id,message_to_send)

a pyExt object performs actions when a message arrives at an inlet. An
integer arriving at inlet 1 could be attached to this method code:

        def int_1(self,*arg):
                print "received integer:",arg[0]

If these pieces of code were in separate python classes - how would I
connect two objects together such that an integer was passed between
the two?

If the first object sent 42, in puredata it would look like this:

http://i44.tinypic.com/15eh74p.gif

useless fact: the screenshot doubles up (i.e. "pyext sender sender")
due to the first word being the python file (i.e. sender.py), whilst
the second is the name of the object class (i.e class sender
(pyext._class)

----
Maybe a more tricky question is:

PureData supports "message busses" - messages sent to named busses can
be broadcast to multiple locations. How would I connect objects up in
this way using python?

a pyExt object registers to receive messages on a certain bus using:

        self._bind(bus_name,self.method_to_call)

        def method_to_call(self,*arg):
                print "a message on", bus_name, "arrived"
                print "the message was", len(arg), "long"
                print "and had the values", arg, "inside"

a pyExt object sends messages to a particular bus by using:

        self._send(bus_name,message_to_send)

* some that parse this into human-readable tokens,
* some that just generate human-readable tokens,


This might be usefull do you intend to release this code??
There are some midi libraries that may be helpful, it is hard to tell
what you need without seeing the code
 
R

responsible7

Hi again,

Comments inline:
This might be usefull do you intend to release this code??

I do, but I want to release it as self contained Python code, at the
moment there are many dependencies. Communication between the classes
relies on py/pyExt, which relies on Flext, which relies on PureData,
which relies on Tk and Wish84, and so on and so on...

The bits of code I have written are just simple "if this string of
bytes arrived, send this string to this other blob of code" so they
don't pull in any other python extensions, it's all core stuff. only
the "send this string" part involves the py/pyExt stuff.
There are some midi libraries that may be helpful, it is hard to tell
what you need without seeing the code

I'm already using pyPortMidi for the midi communication. I'm just
floundering a bit when it comes to understanding how to get the
classes I've written to all exist as objects in "python-land" and
communicate between one another.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top