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:
//WRITE1.ck//
// 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;
}
file.closeFile();
These values can then be read sequentially with
WvIn:
//READ1.ck//
WvIn w => blackhole;
"data.snd" =>
w.path;
float n;
repeat(20)
{
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?
Joel