good ev'ning everyone, some time ago I showed ChucK to my girlfriend and she has been quite enthusiastic about it since then. So thanks for providing this interpreter! Well, right now she's coding a automatic composition tool(in python), which generates some (midi) numbers and prints them on the screen. Since this will be an any-time algorithm, the (actually quite simple) task for the audible back-end - which (she insists) should be written in ChucK - is to read the numbers from standard input and generate matching sounds. So the use-case would look like this:
./compose | chuck play_composition.ck
RTFM and RTFS got me to ConsoleInput and FileIO with the second not being able to connect to stdin. At the moment the only - quite hacked - way (AFAICS) to read /anything/ from stdin looks like this: <<< ConsoleInput in; while(true){ in.prompt(); line= in.getLine(); ... }
This doesn't realize EOFs, but keeps waiting, does it? And since FileIO provides a readInt() function, it would be nice to use it in this case... Is there a way, to read from stdin through some IO-Interface of ChucK or anything else 'official' - aka not stating in the source that it's just something hacked? If not, are there any ideas on implementing this in Version 1.2.1.4 ? Well, that's for now, regards, v4hn
Hi v4hn,
I had a similar issue, stdin/stdout doesn't really work well in ChucK.
However, I gave OSC (http://en.wikipedia.org/wiki/Open_Sound_Control) a try
for ChucK/Python communication. This works really good. Check out pyOSC
(https://trac.v2.nl/wiki/pyOSC) for the Python part and the OSC examples in
the ChucK examples folder.
Greetings,
Tom
-----Oorspronkelijk bericht-----
Van: chuck-users-bounces@lists.cs.princeton.edu
[mailto:chuck-users-bounces@lists.cs.princeton.edu] Namens v4hn
Verzonden: dinsdag 1 juni 2010 23:52
Aan: chuck-users@lists.cs.princeton.edu
Onderwerp: [chuck-users] input | chuck
./compose | chuck play_composition.ck
RTFM and RTFS got me to ConsoleInput and FileIO with the second not being able to connect to stdin. At the moment the only - quite hacked - way (AFAICS) to read /anything/ from stdin looks like this: <<< ConsoleInput in; while(true){ in.prompt(); line= in.getLine(); ... }
This doesn't realize EOFs, but keeps waiting, does it? And since FileIO provides a readInt() function, it would be nice to use it in this case... Is there a way, to read from stdin through some IO-Interface of ChucK or anything else 'official' - aka not stating in the source that it's just something hacked? If not, are there any ideas on implementing this in Version 1.2.1.4 ? Well, that's for now, regards, v4hn
On Wed, Jun 02, 2010 at 12:09:42AM +0200, Tom Aizenberg wrote:
I had a similar issue, stdin/stdout doesn't really work well in ChucK. However, I gave OSC (http://en.wikipedia.org/wiki/Open_Sound_Control) a try for ChucK/Python communication. This works really good. Check out pyOSC (https://trac.v2.nl/wiki/pyOSC) for the Python part and the OSC examples in the ChucK examples folder.
Hey, OSC looks nice indeed. I'll have a closer look at it later, but I suppose, that's the way to go for me.. Thanks for your fast responses, v4hn
I can also suggest, since the original program computing the notes is in Python, that another approach is to have the Python program actually write the whole ChucK program itself, and then execute it. If you don't have any real-time control or computing requirements this works perfectly.
Don't forget the idea that you can create sound-emitting responders to OSC
messages which can be sent from your python program. This further renders
useless the "strong timing" of chuck, in a way... but only where control or
note events are concerned. I've had much success with this method.
mike
On Tue, Jun 1, 2010 at 6:38 PM, Joe McMahon
I can also suggest, since the original program computing the notes is in Python, that another approach is to have the Python program actually write the whole ChucK program itself, and then execute it.
If you don't have any real-time control or computing requirements this works perfectly. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
How about having your chuck program just read from a static, public variable (maybe of an array of numbers) and then have another program (called something like addInt.ck) that appends any integer arguments to the end of the array. That way, your python script could just spork "chuck + addInt.ck 60 64 67" and a C major triad (in midi keys) would be appended to the end of your array. The code for addInt.ck would be something like for (int i; i < argc; i++) { MyIntArray << argv[i]; } Would this work for your purposes? You wouldn't have to deal with any timing issues. If you wanted to deal with duration in the python script, you can just use a multidimensional array. Also, this is assuming that you have chuck in --loop mode, which, let's be honest, is the only way to chuck. Andrew On Jun 1, 2010, at 8:41 PM, mike clemow wrote:
Don't forget the idea that you can create sound-emitting responders to OSC messages which can be sent from your python program. This further renders useless the "strong timing" of chuck, in a way... but only where control or note events are concerned. I've had much success with this method.
mike
On Tue, Jun 1, 2010 at 6:38 PM, Joe McMahon
wrote: I can also suggest, since the original program computing the notes is in Python, that another approach is to have the Python program actually write the whole ChucK program itself, and then execute it. If you don't have any real-time control or computing requirements this works perfectly. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- http://michaelclemow.com http://semiotech.org
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (5)
-
Andrew C. Smith
-
Joe McMahon
-
mike clemow
-
Tom Aizenberg
-
v4hn