There are a lot of functional-ish classes in LiCK, if you wanted to pass around play functions as objects.
class MmlParser
{
Play @ play;
// ... parse stuff, spork ~ play.play(freq, nlength, qlength, vol), ...
}
class Play // "abstract" class, since there are no interfaces in ChucK
{
fun void play(float freq, dur nlength, dur qlength, float vol)
{
// empty
}
}
class PlayNote extends Play
{
SinOsc sin => ADSR adsr => dac;
fun void play(float freq, dur nlength, dur qlength, float vol)
{
freq => sin.freq;
vol => sin.gain;
1 => adsr.keyOn;
nlength => now;
1 => adsr.keyOff;
qlength => now;
}
}
MmlParser mmlParser;
PlayNote playNote;
playNote @=> mmlParser.play;
mmlParser.parse(input);
michael