class MandoPlayer extends Chubgraph { // Four Mando "strings", plus lots of smarts // by Perry R. Cook, March 2013 Mandolin m[4]; m[0] => JCRev rev => dac; m[0].freq(Std.mtof(55)); m[1] => rev; m[0].freq(Std.mtof(62)); m[2] => rev; m[0].freq(Std.mtof(69)); m[3] => rev; m[0].freq(Std.mtof(76)); 0.02 => rev.mix; fun void freqs(float gString, float aString, float dString, float eString) { m[0].freq(gString); m[1].freq(aString); m[2].freq(dString); m[3].freq(eString); } fun void notes(int gNote, int aNote, int dNote, int eNote) { m[0].freq(Std.mtof(gNote)); m[1].freq(Std.mtof(aNote)); m[2].freq(Std.mtof(dNote)); m[3].freq(Std.mtof(eNote)); } fun void strum(dur rate) { for (0 => int i; i < 4; i++) { 1 => m[i].noteOn; rate => now; } } fun void damp(float amount) { // 0.0 = lots of damping, 1.0 = none for (0 => int i; i < 4; i++) { amount => m[i].stringDamping; } } fun void chord(string which) { if (which == "G") this.notes(55,62,71,79); if (which == "D") this.notes(55,64,72,79); if (which == "E") this.notes(57,62,69,78); } } MandoPlayer m; m.chord("G"); m.strum(0.4 :: second); m.chord("D"); m.strum(0.4 :: second); m.chord("G"); m.strum(0.4 :: second); m.chord("E"); m.strum(0.1 :: second); m.strum(0.1 :: second); m.strum(0.1 :: second); m.strum(0.1 :: second); m.chord("G"); m.damp(1.0); m.strum(0.02 :: second); 2.0 :: second => now; m.damp(0.01); 1.0 :: second => now;