initialize.ck
Machine.add(me.dir() + "/Sampler.ck");
Machine.add(me.dir() + "/score.ck");
score.ck
Sampler some_sound;
some_sound.set_sample(-1, "click_01");
Machine.add(me.dir() + "/patterns.ck");
2::second => now;
patterns.ck
Sampler some_sound;
some_sound.mout => dac;
some_sound.trigger(.9, 0);
2::second => now;
Sampler.ck
public class Sampler{
static SndBuf @ sound;
static Mix2 @ mout;
string sound_path;
fun void set_sample(int dir, string wavname){
set_path(dir, wavname);
Mix2 tmix @=> this.mout;
SndBuf tmp => this.mout;
this.sound_path => tmp.read;
tmp.samples() => tmp.pos;
tmp @=> this.sound;
}
fun void trigger(float vol, int pos){
this.sound.gain(vol);
this.sound.pos(pos);
}
fun void set_path(int dir, string wavname){
me.dir(dir) + "/audio/" + wavname + ".wav" => this.sound_path;
}
}