Communicating with external processes
Hi all, What are the ways to communicate between ChucK and external programs? Specifically, my code has a lot of parameters to adjust in real time, and a GUI would be a nice way to do that. I could put the GUI together in PD or Cocoa, but how can I transmit the data to ChucK? The two ways I have found to receive external data are MIDI and OSC. MIDI control changes can be a little coarse in terms of resolution (even with 14-bit values), and for most programs it'll need some sort of loopback driver to handle the routing. OSC seems closer to a generic way of interchanging data, but it looks like I would have to spork a different thread for each parameter I want to receive (since they'd have different addresses), and that I can only receive one value per OSC event. If I wanted, say, to receive 3 floats as part of one message, is there a way to do that? Is there a way to read directly from a pipe to another process? I'm thinking of a setup where an event is signaled when new data is available at the input. Any other thoughts on how to approach this task? Thanks much, Andrew P.S. Semi-related to the above: is there a way to wait on 2 events simultaneously? Thinking of something like these: midiEvent || oscEvent => now; // wait for whichever comes first midiEvent || 200::ms => now; // wait with a timeout
Andrew, It is possible to send multiple (mixed) values in one OSC message. Here is a chunk of code I'm working on to let ChucK send data to Processing. ... // send the OSC data xmit.startMsg( "osc_data", "iiff" ); // <----- note the second string here -- it can be a combination of "i" and "f" and other things col => xmit.addInt; // col is an int declared above this code chunk row => xmit.addInt; // ditto // normalize the 'color' data (values[col][row] / Math.pow(2, bit_depth) + 1) / 2 => float color; color => xmit.addFloat; sounding => xmit.addFloat; // once the last element is added (the "iiff" from above) the message goes out ... For more details, check out the osc examples that come with ChucK, along with the specs on this page: http://opensoundcontrol.org/spec-1_0-examples#OSCstrings I have had good luck this week getting ChucK and Processing to play nice together, for what it is worth. Good night, - Greg On Jan 21, 2009, at 12:29 AM, Andrew McPherson wrote:
Hi all,
What are the ways to communicate between ChucK and external programs? Specifically, my code has a lot of parameters to adjust in real time, and a GUI would be a nice way to do that. I could put the GUI together in PD or Cocoa, but how can I transmit the data to ChucK?
The two ways I have found to receive external data are MIDI and OSC. MIDI control changes can be a little coarse in terms of resolution (even with 14-bit values), and for most programs it'll need some sort of loopback driver to handle the routing.
OSC seems closer to a generic way of interchanging data, but it looks like I would have to spork a different thread for each parameter I want to receive (since they'd have different addresses), and that I can only receive one value per OSC event. If I wanted, say, to receive 3 floats as part of one message, is there a way to do that?
Is there a way to read directly from a pipe to another process? I'm thinking of a setup where an event is signaled when new data is available at the input. Any other thoughts on how to approach this task?
Thanks much, Andrew
P.S. Semi-related to the above: is there a way to wait on 2 events simultaneously? Thinking of something like these:
midiEvent || oscEvent => now; // wait for whichever comes first midiEvent || 200::ms => now; // wait with a timeout_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
If you have MaxMSP, Brad Garton has just released the newest version
of [chuck~] for Max5 (also backward compatible with Max 4.6). If not,
you could check out MAUI with Mini Audicle. All this assumes you have
a Mac, however.
Andrew
On Tue, Jan 20, 2009 at 9:43 PM, Gregory Brown
Andrew,
It is possible to send multiple (mixed) values in one OSC message. Here is a chunk of code I'm working on to let ChucK send data to Processing.
... // send the OSC data xmit.startMsg( "osc_data", "iiff" ); // <----- note the second string here -- it can be a combination of "i" and "f" and other things col => xmit.addInt; // col is an int declared above this code chunk row => xmit.addInt; // ditto // normalize the 'color' data (values[col][row] / Math.pow(2, bit_depth) + 1) / 2 => float color; color => xmit.addFloat; sounding => xmit.addFloat; // once the last element is added (the "iiff" from above) the message goes out ...
For more details, check out the osc examples that come with ChucK, along with the specs on this page:
http://opensoundcontrol.org/spec-1_0-examples#OSCstrings
I have had good luck this week getting ChucK and Processing to play nice together, for what it is worth.
Good night,
- Greg
On Jan 21, 2009, at 12:29 AM, Andrew McPherson wrote:
Hi all,
What are the ways to communicate between ChucK and external programs? Specifically, my code has a lot of parameters to adjust in real time, and a GUI would be a nice way to do that. I could put the GUI together in PD or Cocoa, but how can I transmit the data to ChucK?
The two ways I have found to receive external data are MIDI and OSC. MIDI control changes can be a little coarse in terms of resolution (even with 14-bit values), and for most programs it'll need some sort of loopback driver to handle the routing.
OSC seems closer to a generic way of interchanging data, but it looks like I would have to spork a different thread for each parameter I want to receive (since they'd have different addresses), and that I can only receive one value per OSC event. If I wanted, say, to receive 3 floats as part of one message, is there a way to do that?
Is there a way to read directly from a pipe to another process? I'm thinking of a setup where an event is signaled when new data is available at the input. Any other thoughts on how to approach this task?
Thanks much, Andrew
P.S. Semi-related to the above: is there a way to wait on 2 events simultaneously? Thinking of something like these:
midiEvent || oscEvent => now; // wait for whichever comes first midiEvent || 200::ms => now; // wait with a timeout_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hello Andrew. I've just been working on a similar project that sends OSC from Processing. You can send and receive multiple values with each message. Unfortunately, this doesn't work as midiEvent and oscEvent do not have boolean values: midiEvent || oscEvent => now; // wait for whichever comes first This is how I resolved it: // -------------------------------------------- OscRecv orec; 6449 => orec.port; orec.listen(); orec.event("/foo, i f f f") @=> OscEvent fooData; orec.event("/bar, i f f f") @=> OscEvent barData; while(true) { if (fooData.nextMsg() != 0) { fooData.getInt() => int w; fooData.getFloat() => float p; fooData.getFloat() => float f; fooData.getFloat() => float a; spork ~ foo(w,p,f,a); } if (barData.nextMsg() != 0) { barData.getInt() = int w; barData.getFloat() => float p; barData.getFloat() => float f; barData.getFloat() => float a; spork ~ bar(w,p,f,a); } 5::ms => now; } // --------------END----------------------
2009/1/21 Andrew McPherson
OSC seems closer to a generic way of interchanging data, but it looks like I would have to spork a different thread for each parameter I want to receive (since they'd have different addresses), and that I can only receive one value per OSC event. If I wanted, say, to receive 3 floats as part of one message, is there a way to do that?
Is there a way to read directly from a pipe to another process? I'm thinking of a setup where an event is signaled when new data is available at the input. Any other thoughts on how to approach this task?
OSC is what you want to use. Like Gregory Brown said, you can check the ChucK examples directory for code that receives multiple values in one message. You can use that to get around the problem of waiting on multiple OSC messages (by encoding the type in the data instead of the name), although there's no way to wait on two different events like in the code in your P.S.
Thanks much, Andrew
P.S. Semi-related to the above: is there a way to wait on 2 events simultaneously? Thinking of something like these:
midiEvent || oscEvent => now; // wait for whichever comes first midiEvent || 200::ms => now; // wait with a timeout
-- Tom Lieber http://AllTom.com/
Thanks everyone for the advice-- this is a big help. OSC ought to work
well, and I'm not sure how I missed the MAUI routines seeing as I use
MiniAudicle on Mac!
Andrew
On Wed, Jan 21, 2009 at 8:25 AM, Tom Lieber
OSC seems closer to a generic way of interchanging data, but it looks
2009/1/21 Andrew McPherson
: like I would have to spork a different thread for each parameter I want to receive (since they'd have different addresses), and that I can only receive one value per OSC event. If I wanted, say, to receive 3 floats as part of one message, is there a way to do that? Is there a way to read directly from a pipe to another process? I'm
thinking of a setup where an event is signaled when new data is available at the input. Any other thoughts on how to approach this task?
OSC is what you want to use. Like Gregory Brown said, you can check the ChucK examples directory for code that receives multiple values in one message. You can use that to get around the problem of waiting on multiple OSC messages (by encoding the type in the data instead of the name), although there's no way to wait on two different events like in the code in your P.S.
Thanks much, Andrew
P.S. Semi-related to the above: is there a way to wait on 2 events simultaneously? Thinking of something like these:
midiEvent || oscEvent => now; // wait for whichever comes first midiEvent || 200::ms => now; // wait with a timeout
-- Tom Lieber http://AllTom.com/ _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (5)
-
Andrew C. Smith
-
Andrew McPherson
-
Gregory Brown
-
Joel Matthys
-
Tom Lieber