[chuck-users] Chuck and External audio?

David Powers cyborgk at gmail.com
Fri Jan 19 17:56:22 EST 2007

Hello... Use the SndBuf class to play a sample:

Here's the example code from ChucK docs*:
// the patch
SndBuf buf => dac;
// load the file
"../data/snare.wav" => buf.read;

// time loop
while( true )
    0 => buf.pos;
    Std.rand2f(.2,.9) => buf.gain;
    Std.rand2f(.5,1.5) => buf.rate;
    100::ms => now;

*But note, that code is changing the gain and rate of the sample
randomly - you would want a rate of 1.0 to just play the file at
original speed/pitch.

Anyway, you can just plug SndBuf it into a filter, set the filter ...
and there you go!

Oh and use WvOut to record ChucK output to a file:

"This class provides output support for various audio file formats.
It also serves as a base     class for "realtime" streaming
subclasses... WvOut writes samples to an audio file... WvOut currently
supports WAV, AIFF, AIFC, SND (AU), MAT-file (Matlab), and STK RAW
file formats."

Hope that helps.


On 1/19/07, jochen lists <jochen.lists at gmail.com> wrote:
> hi,
> sorry about this stupid question, but i can't seem to find any
> documentation on how to use chuck to process audio files, i.e. open a
> wav, aiff, whatever and run it through some filters. is this
> possible???
> thx
> - jochen
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

More information about the chuck-users mailing list