// Guitar Riff Lab with MAUI Control Interface // copyright 2008 Les Hall // this software is protected by the GNU General Public License // control variables 2 => int n; // base of count 8 => float notes_per_second; // the timing 8 => int num_digits; // number of digits in base-n count 8 => int num_and_terms; // number of and terms float freq; // the frequency of the next note 0 => int play_note; // 1 to play this note 0 => int and_term; // equal to and_bits if play_note should be true 0 => int and_bits; // number of bits anded in a term int j[num_digits]; // the base-n count MAUI_View control_view; MAUI_Button start_button; MAUI_Button and_buttons[num_and_terms][num_digits]; MAUI_LED count[num_digits]; control_view.size (800, 600); control_view.name ("Boolean Sequencing Guitar Riff Lab"); start_button.toggleType (); start_button.size (120, 60); start_button.position (0, 0); start_button.name ("start/stop"); control_view.addElement (start_button); for (0 => int a; a < num_and_terms; a++) { for (0 => int b; b < num_digits; b++) { and_buttons[a][b].toggleType (); and_buttons[a][b].size (75, 75); and_buttons[a][b].position (50*(num_digits-b-1), 75+50*a); and_buttons[a][b].name ("0"); control_view.addElement (and_buttons[a][b]); } } for (0 => int b; b < num_digits; b++) { count[b].color (count[b].red); count[b].size (50, 50); count[b].position (12+50*(num_digits-b-1), 50); control_view.addElement (count[b]); } control_view.display (); // many thanks to kijjaz for the mandolin-based Stratocaster guitar sound with overdrive: // Mandolin as the electric guitar test: by kijjaz (kijjaz@yahoo.com) // feel free to use, modify, publish class kjzGuitar101 { Mandolin str[3]; // create mandolin strings SinOsc overdrive => NRev rev => Gain output; // create overdrive to reverb to dac overdrive.sync(1); // make overdrive do Sine waveshaping rev.mix(0.02); // set reverb mix rev.gain(0.6); // set master gain output.gain(1.0); // set output gain // connect strings, set string damping for(int i; i < 3; i++) { str[i] => overdrive; .9 => str[i].stringDamping; } } kjzGuitar101 A; // lead guitar A.output => Gain master => dac; 0 => master.op; function void start () { while (true) { // wait for the start button to be pushed start_button => now; !master.op () => master.op; } } spork ~ start (); while (true) { for (0 => j[7]; j[7] < n; j[7]++) { for (0 => j[6]; j[6] < n; j[6]++) { for (0 => j[5]; j[5] < n; j[5]++) { for (0 => j[4]; j[4] < n; j[4]++) { for (0 => j[3]; j[3] < n; j[3]++) { for (0 => j[2]; j[2] < n; j[2]++) { for (0 => j[1]; j[1] < n; j[1]++) { for (0 => j[0]; j[0] < n; j[0]++) { for (0 => int b; b < num_digits; b++) { if (j[b]) { count[b].light (); } else { count[b].unlight (); } } 0 => play_note; for (0 => int a; a < num_and_terms; a++) { 0 => and_term; 0 => and_bits; for (0 => int b; b < num_digits; b++) { if (and_buttons[a][b].state ()) { if (j[b]) { 1 + and_term => and_term; } 1 + and_bits => and_bits; } } if ( (and_term == and_bits) && (and_bits > 0) ) { 1 => play_note; } } if (play_note) { 2*(8 - j[4] - j[3] - j[2] - j[1] - !j[0]) * 10 => freq; A.rev.mix(0.10); // set reverb mix for(int i; i < 3; i++) { 0.5 => A.str[i].stringDamping; } for (0 => int i; i < 3; i++) { freq * (i+1) => A.str[i].freq; } for (0 => int i; i < 3; i++) { 0.8 - i/4.0 => A.str[i].pluck; } } // advance time while (!start_button.state ()) { 1::second => now; } 1::second / notes_per_second => now; } } } } } } } } }