[chuck-users] read/write text from file

Joel Matthys jwmatthys at yahoo.com
Wed Aug 20 22:38:23 EDT 2008

Does ChucK a method of writing and reading ints, floats or strings from a file? The documentation
only includes WvIn and WvOut for file I/O.

I hacked a technique for sending data by scaling it to values -1.0 to 1.0 and sending it to a sound file:


// write values to file
Step x => WvOut file => blackhole;
"data" => file.sndFilename;
float n;
for (int ii; ii<20; ii++)
 ii/20.0 => n;
 <<< n >>>;
 n => x.next;
 1::samp => now;

These values can then be read sequentially with WvIn:


WvIn w => blackhole;
"data.snd" => w.path;
float n;

 1::samp => now;
 w.last() => n;
 <<< n >>>;

But I don't get exactly the same values returned; ie, I try to store the value 0.500000 but when read,
I get 0.500015. That's a significant variance.

Does anyone know where this variance comes from, or how to get around it? And is this the only way
to store and read data? What about strings from files?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080820/338c5336/attachment.htm>

More information about the chuck-users mailing list