[chuck-users] input | chuck <read_stdin_and_do_stuff>

Tom Aizenberg tom at tomaizenberg.nl
Tue Jun 1 18:09:42 EDT 2010


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 at lists.cs.princeton.edu
[mailto:chuck-users-bounces at lists.cs.princeton.edu] Namens v4hn
Verzonden: dinsdag 1 juni 2010 23:52
Aan: chuck-users at lists.cs.princeton.edu
Onderwerp: [chuck-users] input | chuck <read_stdin_and_do_stuff>

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



More information about the chuck-users mailing list