| |
- Pd
- asynchat.async_chat(asyncore.dispatcher)
-
- PdReceive
- PdSend
- exceptions.Exception(exceptions.BaseException)
-
- PdException
class Pd |
|
Start Pure Data in a subprocess.
>>> from time import time, sleep
>>> from os import path, getcwd
>>>
>>> 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 < 20 and pd.Alive():
... if time() - start > 0.5 and not sentexit:
... pd.Send(["exit"])
... sentexit = True
... pd.Update()
...
...
Pd called Pd_hello(['this', 'is', 'my', 'message', 'to', 'python'])
untrapped message: ['this', 'is', 'another', 'message']
untrapped stderr output: "connecting to port 30322"
untrapped stderr output: "python-connected: 0"
untrapped stderr output: "python-connected: 1"
untrapped stderr output: "from-python: test message 1 2 3"
untrapped stderr output: "closing audio..."
untrapped stderr output: "pd_gui: pd process exited"
untrapped stderr output: "closing MIDI..."...
Pd died!
>>> pd.Exit() |
|
Methods defined here:
- Alive(self)
- Check whether the Pd subprocess is still alive.
- CheckStart(self, msg)
- Connect(self, addr)
- Dead(self)
- Error(self, error)
- Override this to catch anything sent by Pd to stderr (e.g. [print] objects).
- Exit(self)
- Kill the Pd process right now.
- PdDied(self)
- Override this to catch the Pd subprocess exiting.
- PdMessage(self, data)
- Override this method to receive messages from Pd.
- PdStarted(self)
- Override this to catch the definitive start of Pd.
- Send(self, msg)
- Send an array of data to Pd.
It will arrive at the [python-interface] object as a space delimited list.
p.Send(["my", "test", "yay"])
- Update(self)
- __init__(self, port=30321, nogui=True, open='python-interface-help.pd', cmd=None, path=['patches'], extra=None, stderr=True)
- port - what port to connect to [netreceive] on.
nogui - boolean: whether to start Pd with or without a gui. Defaults to nogui=True
open - string: full path to a .pd file to open on startup.
cmd - message to send to Pd on startup.
path - an array of paths to add to Pd startup path.
extra - a string containing extra command line arguments to pass to Pd.
Data and other attributes defined here:
- errorCallbacks = {}
|
class PdReceive(asynchat.async_chat) |
| |
- Method resolution order:
- PdReceive
- asynchat.async_chat
- asyncore.dispatcher
Methods defined here:
- __init__(self, parent, localaddr=('127.0.0.1', 30322), map=None)
- collect_incoming_data(self, data)
- found_terminator(self)
- handle_accept_server(self)
- handle_connect(self)
Methods inherited from asynchat.async_chat:
- close_when_done(self)
- automatically close this channel once the outgoing queue is empty
- discard_buffers(self)
- get_terminator(self)
- handle_close(self)
- handle_read(self)
- handle_write(self)
- initiate_send(self)
- push(self, data)
- push_with_producer(self, producer)
- readable(self)
- predicate for inclusion in the readable for select()
- refill_buffer(self)
- # refill the outgoing buffer by calling the more() method
# of the first producer in the queue
- set_terminator(self, term)
- Set the input delimiter. Can be a fixed string of any length, an integer, or None
- writable(self)
- predicate for inclusion in the writable for select()
Data and other attributes inherited from asynchat.async_chat:
- ac_in_buffer_size = 4096
- ac_out_buffer_size = 4096
Methods inherited from asyncore.dispatcher:
- __getattr__(self, attr)
- # cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
- __repr__(self)
- accept(self)
- add_channel(self, map=None)
- bind(self, addr)
- close(self)
- connect(self, address)
- create_socket(self, family, type)
- del_channel(self, map=None)
- handle_accept(self)
- handle_error(self)
- handle_expt(self)
- handle_expt_event(self)
- handle_read_event(self)
- handle_write_event(self)
- listen(self, num)
- log(self, message)
- log_info(self, message, type='info')
- recv(self, buffer_size)
- send(self, data)
- set_reuse_addr(self)
- set_socket(self, sock, map=None)
Data and other attributes inherited from asyncore.dispatcher:
- accepting = False
- addr = None
- closing = False
- connected = False
- debug = False
|
class PdSend(asynchat.async_chat) |
| |
- Method resolution order:
- PdSend
- asynchat.async_chat
- asyncore.dispatcher
Methods defined here:
- Connect(self, addr)
- Send(self, data)
- __init__(self, map=None)
- handle_close(self)
- handle_connect(self)
- handle_expt(self)
Methods inherited from asynchat.async_chat:
- close_when_done(self)
- automatically close this channel once the outgoing queue is empty
- collect_incoming_data(self, data)
- discard_buffers(self)
- found_terminator(self)
- get_terminator(self)
- handle_read(self)
- handle_write(self)
- initiate_send(self)
- push(self, data)
- push_with_producer(self, producer)
- readable(self)
- predicate for inclusion in the readable for select()
- refill_buffer(self)
- # refill the outgoing buffer by calling the more() method
# of the first producer in the queue
- set_terminator(self, term)
- Set the input delimiter. Can be a fixed string of any length, an integer, or None
- writable(self)
- predicate for inclusion in the writable for select()
Data and other attributes inherited from asynchat.async_chat:
- ac_in_buffer_size = 4096
- ac_out_buffer_size = 4096
Methods inherited from asyncore.dispatcher:
- __getattr__(self, attr)
- # cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
- __repr__(self)
- accept(self)
- add_channel(self, map=None)
- bind(self, addr)
- close(self)
- connect(self, address)
- create_socket(self, family, type)
- del_channel(self, map=None)
- handle_accept(self)
- handle_error(self)
- handle_expt_event(self)
- handle_read_event(self)
- handle_write_event(self)
- listen(self, num)
- log(self, message)
- log_info(self, message, type='info')
- recv(self, buffer_size)
- send(self, data)
- set_reuse_addr(self)
- set_socket(self, sock, map=None)
Data and other attributes inherited from asyncore.dispatcher:
- accepting = False
- addr = None
- closing = False
- connected = False
- debug = False
| |