Writing to Disk
by Adam Tindale and Ge Wang
Recording your ChucK session to file is easy!
Say you want to record the output of the following:
%>chuck foo.ck bar.ck
All you have to do is ChucK a shred that writes to file:
%>chuck foo.ck bar.ck rec.ck
No changes to existing files are necessary. An example rec.ck can be found in examples/basic/, this guy/gal writes to “foo.wav”. Edit the file to change the output file. If you don’t want to worry about overwriting the same file everytime, you can substitute rec.ck for rec-auto.ck:
%>chuck foo.ck bar.ck rec-auto.ck
rec-auto.ck will generate a file name using the current time. You can change the prefix of the filename by modifying
"data/session" => w.autoPrefix;
w is the WvOut in the patch.
Oh yeah, you can of course chuck rec.ck on-the-fly.
From terminal 1
%>chuck --loop
From terminal 2
%>⁞chuck + rec.ck
Silent Mode
You can write directly to disk without having real-time audio by starting your programs using the --silent or -s flag.%>chuck foo.ck bar.ck rec2.ck -s
This will not synchronize to the audio card, and will generate samples as fast as it can.
Start and Stop
You can start and stop the writing to file by:1 => w.record; // start 0 => w.record; // stop
As with all things ChucKian, this can be done sample-synchronously.
Another halting problem
What if I have infinite time loop, and want to terminate the VM, will my file be written out correctly? the answer: Ctrl-C works just fine.ChucK STK module keeps track of open file handles and closes them even upon abnormal termination, like Ctrl-C. Actually for many, Ctrl-C is the natural way to end your ChucK session. At any rate, this is quite ghetto, but it works. As for seg-faults and other catastrophic events, like computer catching on fire from ChucK exploding, the file probably is toast.
hmmmm, toast...
The Silent Sample Sucker Strikes Again
As in rec.ck, one patch to write to file is:dac => Gain g => WvOut w => blackhole;
The WvOut writes to file, and also pass through the incoming samples.