pyext for Pure Data

I decided I prefer writing normal logic in a language I’m used to, so I went looking for a Python-external for Pure Data. And sure enough, I found Thomas Grill‘s py/pyext (built upon flext, a C layer for Python externals). I didn’t figure out how to install the binaries (didn’t take the time to experiment) so I just compiled them up. Works great. :-)

Writing externals for this is supersimple:

class example(pyext._class):
  _inlets=2
  _outlets=1

  def _anything_1(self,args):
    print "inlet 2:",args
    self._outlet(1,1)

  def _anything_2(self,args):
    print "inlet 2:",args
    self._outlet(1,2)

This little code should be an external that prints out the argument it receives and sends the inlet number it received the signal on to the outlet.

Share and Enjoy:
  • Print
  • del.icio.us
  • Facebook
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Twitter
niklas

About niklas

Hi. I’m Niklas Saers, often called Nik, and this is my weblog. I make great iOS, Mac and Java software, play the recorder and enjoy life with my beautiful wife. You can learn more about me, view my résumé, or grab me via LinkedIn or Facebook. In addition to this site I am frequently posting thoughts on Twitter and photos on Flickr. You can read more about me and how to get in touch with me here.
This entry was posted in Technology. Bookmark the permalink.

4 Responses to pyext for Pure Data

  1. Phil says:

    Hi,

    Is it possible to write externals that make function calls in python?

    In other words, can you communicate with a driver using python code?

    Phil

  2. niklas niklas says:

    Haven’t tried with a driver, but anything you can do in Python you should be able to do through an external. For DSP work I suppose there is a real-time criteria, though :-)

  3. Thomas Grill says:

    Hi Niklas,
    two small remarks:
    - the syntax with _inlets and _outlets defined within the class is deprecated. You should define the number of inlets and outlets as creation args of the pyext object, like [pyext 1 1 mymod.myclass]

    - flext is a C++ layer for cross-platform externals (between Pd and Max)… it’s not specifically for Python, although pyext uses the flext library.

    have fun, Thomas

  4. niklas niklas says:

    Hi Thomas, thanks for your update. I should really get around to writing an update of what the world looks like in 2010 :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>