What's the most appropriate way to pass an external value into a puredata patch (ultimately in to a number box)?
Thanks
How to pass a variable in to puredata
What's the most appropriate way to pass an external value into a puredata patch (ultimately in to a number box)?
Thanks
So, I just read the value from a file. I thought there might be some other way.
It depends on your setup really. You could use OSC or MIDI or even embed pd in another app with libpd and send messages that way.
you could use the [netrecieve] object in the pd patch then just send the value over tcp or udp using something like netcat or some language's networking library. There are are also pdsend and pdreceive programs that come with vanilla (and maybe extended, I don't know) that simplify passing data to pd over tcp or udp.
Or, if you want to just pass some variable to your patch from the command line at launch you can use the -send command line flag to do something like
pd -open "mypatch.pd" -send "; myVar1 45; mayVar2 67"
which would launch pd, open mypatch.pd and send 45 to a [receive myVar1] object and 67 to a [receive myVar2] object.
hello all,
thanks portabello for your example. This is what i need and it works fine with the windows cmd line.
But i cannot manage to pass a string instead a number.
When i pass :
pd -open "mypatch.pd" -send "; myVar1 45; mayVar2 hello"
i get the error :
error: gatom: no method for 'hello'
i tried alternatives such as :
pd -open "mypatch.pd" -send "; myVar1 45; mayVar2 'hello'"
pd -open "mypatch.pd" -send "; myVar1 45; mayVar2 \"hello\""
pd -open "mypatch.pd" -send "; myVar1 45; mayVar2 message hello"
but nothing worked.
Do you have any idea ?
Ok i just found the answer.
The 'atoms' (number boxes) cannot receive directly a message. I used the list2symbol object to convert it :
[receive mayVar2]
|
|
[list2symbol]
|
|
[hello \
and it works.
other useful variable passing methods include [netsend] and [netreceive], [sendOSC] and [OSCdump]. [textfile] and [qlist] can pass variables via hd writes and reads, and [shell] can execute shell scripts and return the STDout through outlet 1.
any technology distinguishable from magic
is insufficiently advanced.
Oops! Looks like something went wrong!