Skip to content

Instantly share code, notes, and snippets.

Created November 18, 2013 14:22
Show Gist options
  • Save anonymous/7528545 to your computer and use it in GitHub Desktop.
Save anonymous/7528545 to your computer and use it in GitHub Desktop.
test
// doesn't matter what size, we're using a different
// part of the array, the "associative" part
me.dir() + "/audio/" => string path;
["kick_01", "click_01", "click_02"
] @=> string sample_list[];
// doesn't matter what size as long as it's 0 or more.
// If you only want an array of object references use @:
SndBuf @ samples[0];
// When declaring an array of objects, the objects inside
// the array are automatically instantiated
// http://chuck.cs.princeton.edu/doc/language/array.html
for(0 => int i; i<sample_list.cap(); i++){
sample_list[i] => string sname;
new SndBuf @=> samples[sname];
path + sname + ".wav" => samples[sname].read;
samples[sname].samples() => samples[sname].pos;
}
// send them all to a part of the chain, here simply dac
for(0 => int s; s<sample_list.cap(); s++){
samples[sample_list[s]] => dac;
}
for(0 => int i; i<6; i++){
1740 => samples["kick_01"].pos;
0.9 => samples["kick_01"].rate;
0.25::second => now;
1740 => samples["click_01"].pos;
1.2 => samples["click_01"].rate;
0.25::second => now;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment