[chuck-users] Useful code snippet: writing to mono or stereo files
mike clemow
gelfmuse at gmail.com
Sun May 3 12:16:13 EDT 2009
Robert,
This is handy, thanks. Also, I suppose WvOut really ought to get an
update to handle stereo files...
_MIke
2009/4/28 Robert Poor <rdpoor at gmail.com>:
> Thanks to a tip from Tom Lieber (who pointed out that WvOut doesn't actually
> handle stereo files), here's a snippet of ChucK code people might find
> useful:
>
> if (me.args() > 1) {
> dac.chan(0) => Gain g0 => WvOut w0 => blackhole;
> dac.chan(1) => Gain g1 => WvOut w1 => blackhole;
> 0.5 => g0.gain;
> 0.5 => g1.gain;
> me.arg(0) => w0.wavFilename;
> me.arg(1) => w1.wavFilename;
> <<< "writing stereo output to files", me.arg(0), me.arg(1) >>>;
> } else if (me.args() > 0) {
> dac => Gain g => WvOut w => blackhole;
> 0.5 => g.gain;
> me.arg(0) => w.wavFilename;
> <<< "writing mono output to file", me.arg(0) >>>;
> }
>
> Since it attaches to the dac, you can put it just about anywhere in your
> ChucK program. When you invoke chuck as in :
>
> % chuck mytest.ck:bleeep.wav
>
> it will write everything your program sends to the dac to a mono
> "bleeep.wav" file. If you invoke it as in:
>
> % chuck mytest.ck:bleep_0.wav:bleep_1.wav
>
> it will write everything you program sends to the dac to two mono files:
> bleep_0.wav (left channel) andn bleep_1.wav (right channel). It's up to you
> to weave the two files together into a stereo sound file. There are several
> ways to do it -- I tend to use Audacity.
>
> - Rob
>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>
--
http://michaelclemow.com
http://semiotech.org
More information about the chuck-users
mailing list