// Guitar 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 12 => int num_digits; // number of digits in base-n count 8 => int num_and_terms; // number of and terms 2 => int num_and_pages; // number of pages of and terms 0 => int and_page; // the current and page 0 => int instrument; // the current instrument 11 => int num_instruments; // number of instruments 9 => int num_scales; // number of scales 0 => int scale; // the current scale index [20.0, 60.0, 30.0, 30.0, 30.0, 40.0, 20.0, 20.0, 20.0, 20.0, 30.0] @=> float freq_offset_values[]; // frequency offset values int freq; // the frequency index of the next note float frequency; // the frequency of the next note int play_note; // 1 to play this note int page_term_index; // holds calculated index value int dont_care; // adds up don't care bits int and_term; // 1 if play_note should be true float playback_rate; // 1 for normal speed, 16 for fast forward int j[num_digits]; // the base-n count int freq_amount[num_instruments][num_digits]; // frequency bit values int note[num_instruments][num_and_pages][num_and_terms]; // notes to play int and_values[num_instruments][num_and_pages*num_and_terms][num_digits]; // holds current value of buttons int note_prob[num_digits]; // the note probability for each bit position // variables for handling shred sporking and shred removing int shred_id_frequency_offset; int shred_id_and_buttons[num_and_terms][num_digits]; int shred_id_plus_buttons[num_digits]; int shred_id_minus_buttons[num_digits]; int shred_id_note_plus_buttons[num_and_terms]; int shred_id_note_minus_buttons[num_and_terms]; int shred_id_scales[num_scales]; 10 => int num_guitar_shreds; int shred_id_guitar[num_guitar_shreds]; 7 => int num_flute_shreds; int shred_id_flute[num_flute_shreds]; 5 => int num_snare_shreds; int shred_id_snare[num_snare_shreds]; 8 => int num_drum_shreds; int shred_id_drum[num_drum_shreds]; 12 => int num_mandolin_shreds; int shred_id_mandolin[num_mandolin_shreds]; 10 => int num_saxophone_shreds; int shred_id_saxophone[num_saxophone_shreds]; 1 => int num_thunder_shreds; int shred_id_thunder[num_thunder_shreds]; 1 => int num_delaysnare_shreds; int shred_id_delaysnare[num_delaysnare_shreds]; 5 => int num_mic_shreds; int shred_id_mic[num_mic_shreds]; 5 => int num_shakers_shreds; int shred_id_shakers[num_shakers_shreds]; 5 => int num_stifkarp_shreds; int shred_id_stifkarp[num_stifkarp_shreds]; 3 => int num_ocean1_shreds; int shred_id_ocean1[num_ocean1_shreds]; 2 => int num_rain1_shreds; int shred_id_rain1[num_rain1_shreds]; 1 => int num_rain2_shreds; int shred_id_rain2[num_rain2_shreds]; 2 => int num_effects_shreds; int shred_id_effects[num_effects_shreds]; MAUI_View control_view; MAUI_View string_view; MAUI_View percussion_view; MAUI_View wind_view; MAUI_View scales_view; MAUI_Button start_button, record_button, clear_button, ffwd_button; MAUI_Button instrument_minus_button, instrument_plus_button, instrument_button; MAUI_Button xor_button; MAUI_Button and_buttons[num_and_terms][num_digits]; MAUI_Button and_plus_button, and_minus_button, and_page_button; MAUI_LED count[num_digits]; MAUI_LED logic[num_and_terms]; MAUI_LED playing_note; MAUI_Button plus_buttons[num_digits]; MAUI_Button minus_buttons[num_digits]; MAUI_Button freq_buttons[num_digits]; MAUI_Button note_plus_buttons[num_and_terms]; MAUI_Button note_minus_buttons[num_and_terms]; MAUI_Button note_buttons[num_and_terms]; MAUI_Slider master_volume; MAUI_Slider base; MAUI_Slider freq_offset; MAUI_Slider notes_per_second; MAUI_Slider reverb, body_size, pluck_pos; MAUI_Slider string_damping, string_detune, after_touch; MAUI_Slider guitar_echo_delay, guitar_echo_max, guitar_echo_mix; MAUI_Slider jet_delay, jet_reflection, end_reflection; MAUI_Slider noise_gain, vibrato_freq, vibrato_gain; MAUI_Slider snare_freq, snare_Q, snare_decay, snare_attack; MAUI_Slider drum_freq, drum_pitch_decay, drum_pitch_attack; MAUI_Slider drum_decay, drum_attack, drum_drive_gain; MAUI_Slider drum_filter; MAUI_Slider mandolin_body_size, mandolin_pluck_pos, mandolin_after_touch; MAUI_Slider mandolin_string_damping, mandolin_string_detune; MAUI_Slider mandolin_gain1, mandolin_gain2; MAUI_Slider saxophone_stiffness, saxophone_aperture, saxophone_pressure; MAUI_Slider saxophone_noise_gain, saxophone_vibrato_freq, saxophone_vibrato_gain; MAUI_Slider saxophone_blow_position, saxophone_rate, saxophone_reverb; MAUI_Slider thunder_probability; MAUI_Slider mic_chorus_mod_freq, mic_chorus_mod_depth, mic_chorus_mix; MAUI_Slider mic_nrev_mix; MAUI_Slider shakers_preset, shakers_objects, shakers_decay, shakers_energy; MAUI_Slider stifkarp_pickupPosition, stifkarp_sustain; MAUI_Slider stifkarp_stretch, stifkarp_baseLoopGain; MAUI_Slider wahwah_freq, jcreverb_mix; MAUI_Button Guitar, Flute, Snare, Drum; MAUI_Button Mandolin, Saxophone, Thunder, DelaySnare; MAUI_Button Microphone, Shakers, StifKarp; MAUI_Button WahWah, JCReverb, Ocean1, Rain1, Rain2; MAUI_Slider guitar_gain, flute_gain, snare_gain, drum_gain; MAUI_Slider mandolin_gain, saxophone_gain, thunder_gain, delaysnare_gain; MAUI_Slider microphone_gain, shakers_gain, stifkarp_gain, ocean1_gain; MAUI_Slider rain1_gain, rain2_gain; MAUI_Button M1_Dyno_limit, M1_Dyno_compress, M1_Dyno_expand, M1_Dyno_gate; MAUI_Button scales[num_scales]; MAUI_Button author; control_view.size (800, 600); control_view.name ("Guitar Lab - Logic Matrix"); string_view.size (800, 600); string_view.name ("Guitar Lab - String Instruments"); percussion_view.size (800, 600); percussion_view.name ("Guitar Lab - Percussion Instruments"); wind_view.size (800, 600); wind_view.name ("Guitar Lab - Wind Instruments"); scales_view.size (800, 600); scales_view.name ("Guitar Lab - Scales"); start_button.toggleType (); start_button.size (100, 60); start_button.position (360, 0); start_button.name ("Play"); control_view.addElement (start_button); record_button.toggleType (); record_button.size (100, 60); record_button.position (440, 0); record_button.name ("Record"); control_view.addElement (record_button); clear_button.pushType (); clear_button.size (100, 60); clear_button.position (600, 0); clear_button.name ("Clear"); control_view.addElement (clear_button); ffwd_button.pushType (); ffwd_button.size (100, 60); ffwd_button.position (520, 0); ffwd_button.name ("FFwd"); control_view.addElement (ffwd_button); xor_button.toggleType (); xor_button.size (100, 60); xor_button.position (680, 0); xor_button.name ("OR"); control_view.addElement (xor_button); instrument_plus_button.pushType (); instrument_plus_button.size (60, 60); instrument_plus_button.position (120, 0); instrument_plus_button.name ("+"); control_view.addElement (instrument_plus_button); instrument_minus_button.pushType (); instrument_minus_button.size (60, 60); instrument_minus_button.position (0, 0); instrument_minus_button.name ("-"); control_view.addElement (instrument_minus_button); instrument_button.pushType (); instrument_button.size (120, 60); instrument_button.position (30, 0); instrument_button.name ("Guitar"); control_view.addElement (instrument_button); and_plus_button.pushType (); and_plus_button.size (60, 60); and_plus_button.position (300, 0); and_plus_button.name ("+"); control_view.addElement (and_plus_button); and_minus_button.pushType (); and_minus_button.size (60, 60); and_minus_button.position (180, 0); and_minus_button.name ("-"); control_view.addElement (and_minus_button); and_page_button.pushType (); and_page_button.size (120, 60); and_page_button.position (210, 0); and_page_button.name ("page " + and_page); control_view.addElement (and_page_button); for (0 => int a; a < num_and_terms; a++) { for (0 => int b; b < num_digits; b++) { for (0 => int p; p < num_and_pages; p++) { 0 => and_values[instrument][p*num_and_terms+a][b]; } and_buttons[a][b].pushType (); and_buttons[a][b].size (65, 65); and_buttons[a][b].position (40*(num_digits-b-1), 75+40*a); and_buttons[a][b].name (""); 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 (8+40*(num_digits-b-1), 42); control_view.addElement (count[b]); } for (0 => int a; a < num_and_terms; a++) { logic[a].color (logic[a].green); logic[a].size (50, 50); logic[a].position (8+40*num_digits, 82+40*a); control_view.addElement (logic[a]); } playing_note.color (playing_note.blue); playing_note.size (50, 50); playing_note.position (8+40*num_digits, 42); control_view.addElement (playing_note); for (0 => int b; b < num_digits; b++) { plus_buttons[b].pushType (); plus_buttons[b].size (60, 60); plus_buttons[b].position (40*(num_digits-b-1)+2, 40+10+40*(num_and_terms+1)); plus_buttons[b].name ("+"); control_view.addElement (plus_buttons[b]); } for (0 => int b; b < num_digits; b++) { minus_buttons[b].pushType (); minus_buttons[b].size (60, 60); minus_buttons[b].position (40*(num_digits-b-1)+2, 40-5+40*(num_and_terms+3)); minus_buttons[b].name ("-"); control_view.addElement (minus_buttons[b]); } for (0 => int b; b < num_digits; b++) { for (0 => int i; i < num_instruments; i++) { 0 => freq_amount[i][b]; } freq_buttons[b].pushType (); freq_buttons[b].size (65, 65); freq_buttons[b].position (40*(num_digits-b-1), 40+40*(num_and_terms+2)); freq_buttons[b].name ("" + freq_amount[instrument][b]); control_view.addElement (freq_buttons[b]); } for (0 => int b; b < num_and_terms; b++) { note_plus_buttons[b].pushType (); note_plus_buttons[b].size (60, 60); note_plus_buttons[b].position (40*(num_digits+1)+60, 75+40*b+2); note_plus_buttons[b].name ("+"); control_view.addElement (note_plus_buttons[b]); } for (0 => int b; b < num_and_terms; b++) { note_minus_buttons[b].pushType (); note_minus_buttons[b].size (60, 60); note_minus_buttons[b].position (40*(num_digits+1), 75+40*b+2); note_minus_buttons[b].name ("-"); control_view.addElement (note_minus_buttons[b]); } for (0 => int b; b < num_and_terms; b++) { for (0 => int p; p < num_and_pages; p++) { for (0 => int i; i < num_instruments; i++) { 5 => note[i][p][b]; } } note_buttons[b].pushType (); note_buttons[b].size (65, 65); note_buttons[b].position (40*(num_digits+1)+28, 75+40*b); note_buttons[b].name ("" + note[instrument][0][b]); control_view.addElement (note_buttons[b]); } "Volume" => master_volume.name; master_volume.range (0, 1); master_volume.value (0.5); master_volume.size (140, 75); master_volume.position (650, 400); master_volume.displayFormat (master_volume.integerFormat); control_view.addElement (master_volume); "Base" => base.name; base.range (2, 10); base.value (2); base.size (140, 75); base.position (650, 450); base.displayFormat (base.integerFormat); control_view.addElement (base); "Base Note" => freq_offset.name; freq_offset.range (0, 127); freq_offset.value (freq_offset_values[instrument]); freq_offset.size (140, 75); freq_offset.position (500, 450); freq_offset.displayFormat (freq_offset.integerFormat); control_view.addElement (freq_offset); "Notes/Sec" => notes_per_second.name; notes_per_second.range (1, 16); notes_per_second.value (6); notes_per_second.size (140, 75); notes_per_second.position (500, 400); notes_per_second.displayFormat (notes_per_second.integerFormat); control_view.addElement (notes_per_second); "Reverb" => reverb.name; reverb.range (0, 1); reverb.value (0.1); reverb.size (200, 75); reverb.position (150, 0); string_view.addElement (reverb); "Body Size" => body_size.name; body_size.range (0, 1); body_size.value (0.3); body_size.size (200, 75); body_size.position (350, 0); string_view.addElement (body_size); "Pluck Pos" => pluck_pos.name; pluck_pos.range (0, 1); pluck_pos.value (0.3); pluck_pos.size (200, 75); pluck_pos.position (550, 0); string_view.addElement (pluck_pos); "String Damping" => string_damping.name; string_damping.range (0, 1); string_damping.value (0.3); string_damping.size (200, 75); string_damping.position (150, 50); string_view.addElement (string_damping); "String Detune" => string_detune.name; string_detune.range (0, 1); string_detune.value (0.3); string_detune.size (200, 75); string_detune.position (350, 50); string_view.addElement (string_detune); "After Touch" => after_touch.name; after_touch.range (0, 1); after_touch.value (0.3); after_touch.size (200, 75); after_touch.position (550, 50); string_view.addElement (after_touch); "Echo Delay" => guitar_echo_delay.name; guitar_echo_delay.range (0, 1); guitar_echo_delay.value (0.2); guitar_echo_delay.size (200, 75); guitar_echo_delay.position (150, 100); string_view.addElement (guitar_echo_delay); "Echo Max" => guitar_echo_max.name; guitar_echo_max.range (0, 10); guitar_echo_max.value (5); guitar_echo_max.size (200, 75); guitar_echo_max.position (350, 100); string_view.addElement (guitar_echo_max); "Echo Mix" => guitar_echo_mix.name; guitar_echo_mix.range (0, 1); guitar_echo_mix.value (0.3); guitar_echo_mix.size (200, 75); guitar_echo_mix.position (550, 100); string_view.addElement (guitar_echo_mix); "Jet Delay" => jet_delay.name; jet_delay.range (0, 1); jet_delay.value (0.3); jet_delay.size (200, 75); jet_delay.position (150, 200); wind_view.addElement (jet_delay); "Jet Reflection" => jet_reflection.name; jet_reflection.range (0, 1); jet_reflection.value (0.9); jet_reflection.size (200, 75); jet_reflection.position (350, 200); wind_view.addElement (jet_reflection); "End Reflection" => end_reflection.name; end_reflection.range (0, 1); end_reflection.value (0.9); end_reflection.size (200, 75); end_reflection.position (550, 200); wind_view.addElement (end_reflection); "Noise Gain" => noise_gain.name; noise_gain.range (0, 1); noise_gain.value (0.5); noise_gain.size (200, 75); noise_gain.position (150, 250); wind_view.addElement (noise_gain); "Vibrato Freq" => vibrato_freq.name; vibrato_freq.range (0, 12); vibrato_freq.value (5); vibrato_freq.size (200, 75); vibrato_freq.position (350, 250); wind_view.addElement (vibrato_freq); "Vibrato Gain" => vibrato_gain.name; vibrato_gain.range (0, 1); vibrato_gain.value (0.5); vibrato_gain.size (200, 75); vibrato_gain.position (550, 250); wind_view.addElement (vibrato_gain); "Frequency" => snare_freq.name; snare_freq.range (0, 10000); snare_freq.value (3000); snare_freq.size (200, 75); snare_freq.position (150, 0); percussion_view.addElement (snare_freq); "Q" => snare_Q.name; snare_Q.range (0, 100); snare_Q.value (10); snare_Q.size (200, 75); snare_Q.position (350, 0); percussion_view.addElement (snare_Q); "Decay" => snare_decay.name; snare_decay.range (0, 10000); snare_decay.value (5000); snare_decay.size (200, 75); snare_decay.position (550, 0); percussion_view.addElement (snare_decay); "Attack" => snare_attack.name; snare_attack.range (0, 10000); snare_attack.value (2000); snare_attack.size (200, 75); snare_attack.position (150, 50); percussion_view.addElement (snare_attack); "Frequency" => drum_freq.name; drum_freq.range (0, 1000); drum_freq.value (100); drum_freq.size (200, 75); drum_freq.position (150, 100); percussion_view.addElement (drum_freq); "Pitch Decay" => drum_pitch_decay.name; drum_pitch_decay.range (0.99, 0.9999); drum_pitch_decay.value (0.999); drum_pitch_decay.size (200, 75); drum_pitch_decay.position (350, 100); percussion_view.addElement (drum_pitch_decay); "Pitch Attack" => drum_pitch_attack.name; drum_pitch_attack.range (0, 1000); drum_pitch_attack.value (100); drum_pitch_attack.size (200, 75); drum_pitch_attack.position (550, 100); percussion_view.addElement (drum_pitch_attack); "Decay" => drum_decay.name; drum_decay.range (0.99, 0.9999); drum_decay.value (0.999); drum_decay.size (200, 75); drum_decay.position (150, 150); percussion_view.addElement (drum_decay); "Attack" => drum_attack.name; drum_attack.range (0, 1000); drum_attack.value (100); drum_attack.size (200, 75); drum_attack.position (350, 150); percussion_view.addElement (drum_attack); "Drive Gain" => drum_drive_gain.name; drum_drive_gain.range (0, 1); drum_drive_gain.value (0.75); drum_drive_gain.size (200, 75); drum_drive_gain.position (550, 150); percussion_view.addElement (drum_drive_gain); "Filter" => drum_filter.name; drum_filter.range (0, 1000); drum_filter.value (500); drum_filter.size (200, 75); drum_filter.position (150, 200); percussion_view.addElement (drum_filter); "Body Size" => mandolin_body_size.name; mandolin_body_size.range (0, 1); mandolin_body_size.value (0.3); mandolin_body_size.size (200, 75); mandolin_body_size.position (150, 200); string_view.addElement (mandolin_body_size); "Pluck Pos" => mandolin_pluck_pos.name; mandolin_pluck_pos.range (0, 1); mandolin_pluck_pos.value (0.3); mandolin_pluck_pos.size (200, 75); mandolin_pluck_pos.position (350, 200); string_view.addElement (mandolin_pluck_pos); "String Damping" => mandolin_string_damping.name; mandolin_string_damping.range (0, 1); mandolin_string_damping.value (0.3); mandolin_string_damping.size (200, 75); mandolin_string_damping.position (150, 250); string_view.addElement (mandolin_string_damping); "String Detune" => mandolin_string_detune.name; mandolin_string_detune.range (0, 1); mandolin_string_detune.value (0.3); mandolin_string_detune.size (200, 75); mandolin_string_detune.position (350, 250); string_view.addElement (mandolin_string_detune); "After Touch" => mandolin_after_touch.name; mandolin_after_touch.range (0, 1); mandolin_after_touch.value (0.3); mandolin_after_touch.size (200, 75); mandolin_after_touch.position (550, 200); string_view.addElement (mandolin_after_touch); "Gain 1" => mandolin_gain1.name; mandolin_gain1.range (0, 3); mandolin_gain1.value (1); mandolin_gain1.size (200, 75); mandolin_gain1.position (150, 300); string_view.addElement (mandolin_gain1); "Gain 2" => mandolin_gain2.name; mandolin_gain2.range (0, 3); mandolin_gain2.value (1); mandolin_gain2.size (200, 75); mandolin_gain2.position (350, 300); string_view.addElement (mandolin_gain2); "Stiffness" => saxophone_stiffness.name; saxophone_stiffness.range (0, 1); saxophone_stiffness.value (0.0); saxophone_stiffness.size (200, 75); saxophone_stiffness.position (150, 0); wind_view.addElement (saxophone_stiffness); "Aperture" => saxophone_aperture.name; saxophone_aperture.range (0, 1); saxophone_aperture.value (0); saxophone_aperture.size (200, 75); saxophone_aperture.position (350, 0); wind_view.addElement (saxophone_aperture); "Pressure" => saxophone_pressure.name; saxophone_pressure.range (0, 1); saxophone_pressure.value (0.8); saxophone_pressure.size (200, 75); saxophone_pressure.position (550, 0); wind_view.addElement (saxophone_pressure); "Noise Gain" => saxophone_noise_gain.name; saxophone_noise_gain.range (0, 1); saxophone_noise_gain.value (0.5); saxophone_noise_gain.size (200, 75); saxophone_noise_gain.position (150, 50); wind_view.addElement (saxophone_noise_gain); "Vibrato Freq" => saxophone_vibrato_freq.name; saxophone_vibrato_freq.range (0, 12); saxophone_vibrato_freq.value (5); saxophone_vibrato_freq.size (200, 75); saxophone_vibrato_freq.position (350, 50); wind_view.addElement (saxophone_vibrato_freq); "Vibrato Gain" => saxophone_vibrato_gain.name; saxophone_vibrato_gain.range (0, 1); saxophone_vibrato_gain.value (0.5); saxophone_vibrato_gain.size (200, 75); saxophone_vibrato_gain.position (550, 50); wind_view.addElement (saxophone_vibrato_gain); "Blow Position" => saxophone_blow_position.name; saxophone_blow_position.range (0, 1); saxophone_blow_position.value (0.3); saxophone_blow_position.size (200, 75); saxophone_blow_position.position (150, 100); wind_view.addElement (saxophone_blow_position); "Rate" => saxophone_rate.name; saxophone_rate.range (0, 10); saxophone_rate.value (5); saxophone_rate.size (200, 75); saxophone_rate.position (350, 100); wind_view.addElement (saxophone_rate); "Reverb" => saxophone_reverb.name; saxophone_reverb.range (0, 1); saxophone_reverb.value (0.3); saxophone_reverb.size (200, 75); saxophone_reverb.position (550, 100); wind_view.addElement (saxophone_reverb); "Probability" => thunder_probability.name; thunder_probability.range (0, 1); thunder_probability.value (0.3); thunder_probability.size (200, 75); thunder_probability.position (150, 250); percussion_view.addElement (thunder_probability); "Chorus Mod Freq" => mic_chorus_mod_freq.name; mic_chorus_mod_freq.range (0, 1000); mic_chorus_mod_freq.value (100); mic_chorus_mod_freq.size (200, 75); mic_chorus_mod_freq.position (150, 350); wind_view.addElement (mic_chorus_mod_freq); "Chorus Mod Depth" => mic_chorus_mod_depth.name; mic_chorus_mod_depth.range (0, 1); mic_chorus_mod_depth.value (0.5); mic_chorus_mod_depth.size (200, 75); mic_chorus_mod_depth.position (350, 350); wind_view.addElement (mic_chorus_mod_depth); "Chorus Mix" => mic_chorus_mix.name; mic_chorus_mix.range (0, 1); mic_chorus_mix.value (0); mic_chorus_mix.size (200, 75); mic_chorus_mix.position (550, 350); wind_view.addElement (mic_chorus_mix); "Reverb" => mic_nrev_mix.name; mic_nrev_mix.range (0, 1); mic_nrev_mix.value (0.2); mic_nrev_mix.size (200, 75); mic_nrev_mix.position (150, 400); wind_view.addElement (mic_nrev_mix); "Preset" => shakers_preset.name; shakers_preset.range (2, 22); shakers_preset.value (4); shakers_preset.size (200, 75); shakers_preset.position (150, 450); shakers_preset.displayFormat (shakers_preset.integerFormat); percussion_view.addElement (shakers_preset); "Objects" => shakers_objects.name; shakers_objects.range (0, 127); shakers_objects.value (10); shakers_objects.size (200, 75); shakers_objects.position (350, 450); shakers_objects.displayFormat (shakers_objects.integerFormat); percussion_view.addElement (shakers_objects); "Decay" => shakers_decay.name; shakers_decay.range (0, 1); shakers_decay.value (0.5); shakers_decay.size (200, 75); shakers_decay.position (550, 450); percussion_view.addElement (shakers_decay); "Energy" => shakers_energy.name; shakers_energy.range (0, 1); shakers_energy.value (0.5); shakers_energy.size (200, 75); shakers_energy.position (150, 500); percussion_view.addElement (shakers_energy); "Pickup Pos" => stifkarp_pickupPosition.name; stifkarp_pickupPosition.range (0, 1); stifkarp_pickupPosition.value (0.2); stifkarp_pickupPosition.size (200, 75); stifkarp_pickupPosition.position (150, 400); string_view.addElement (stifkarp_pickupPosition); "Sustain" => stifkarp_sustain.name; stifkarp_sustain.range (0, 1); stifkarp_sustain.value (0.5); stifkarp_sustain.size (200, 75); stifkarp_sustain.position (350, 400); string_view.addElement (stifkarp_sustain); "Stretch" => stifkarp_stretch.name; stifkarp_stretch.range (0, 1); stifkarp_stretch.value (0.5); stifkarp_stretch.size (200, 75); stifkarp_stretch.position (550, 400); string_view.addElement (stifkarp_stretch); "Base Loop Gain" => stifkarp_baseLoopGain.name; stifkarp_baseLoopGain.range (0, 1); stifkarp_baseLoopGain.value (1); stifkarp_baseLoopGain.size (200, 75); stifkarp_baseLoopGain.position (150, 450); string_view.addElement (stifkarp_baseLoopGain); "Frequency" => wahwah_freq.name; wahwah_freq.range (0, 60); wahwah_freq.value (10); wahwah_freq.size (200, 75); wahwah_freq.position (350, 0); wahwah_freq.displayFormat (wahwah_freq.integerFormat); scales_view.addElement (wahwah_freq); "Mix" => jcreverb_mix.name; jcreverb_mix.range (0, 1); jcreverb_mix.value (0.2); jcreverb_mix.size (200, 75); jcreverb_mix.position (350, 100); scales_view.addElement (jcreverb_mix); "Gain" => guitar_gain.name; guitar_gain.range (0, 1); guitar_gain.value (0.5); guitar_gain.size (150, 75); guitar_gain.position (0, 35); string_view.addElement (guitar_gain); "Gain" => flute_gain.name; flute_gain.range (0, 1); flute_gain.value (0.5); flute_gain.size (150, 75); flute_gain.position (0, 235); wind_view.addElement (flute_gain); "Gain" => snare_gain.name; snare_gain.range (0, 1); snare_gain.value (0.5); snare_gain.size (150, 75); snare_gain.position (0, 35); percussion_view.addElement (snare_gain); "Gain" => drum_gain.name; drum_gain.range (0, 5); drum_gain.value (2.5); drum_gain.size (150, 75); drum_gain.position (0, 135); percussion_view.addElement (drum_gain); "Gain" => mandolin_gain.name; mandolin_gain.range (0, 1); mandolin_gain.value (0.5); mandolin_gain.size (150, 75); mandolin_gain.position (0, 235); string_view.addElement (mandolin_gain); "Gain" => saxophone_gain.name; saxophone_gain.range (0, 1); saxophone_gain.value (0.5); saxophone_gain.size (150, 75); saxophone_gain.position (0, 35); wind_view.addElement (saxophone_gain); "Gain" => thunder_gain.name; thunder_gain.range (0, 5); thunder_gain.value (2.5); thunder_gain.size (150, 75); thunder_gain.position (0, 285); percussion_view.addElement (thunder_gain); "Gain" => delaysnare_gain.name; delaysnare_gain.range (0, 1); delaysnare_gain.value (0.5); delaysnare_gain.size (150, 75); delaysnare_gain.position (0, 385); percussion_view.addElement (delaysnare_gain); "Gain" => microphone_gain.name; microphone_gain.range (0, 5); microphone_gain.value (2.5); microphone_gain.size (150, 75); microphone_gain.position (0, 385); wind_view.addElement (microphone_gain); "Gain" => shakers_gain.name; shakers_gain.range (0, 1); shakers_gain.value (0.5); shakers_gain.size (150, 75); shakers_gain.position (0, 485); percussion_view.addElement (shakers_gain); "Gain" => stifkarp_gain.name; stifkarp_gain.range (0, 1); stifkarp_gain.value (0.5); stifkarp_gain.size (150, 75); stifkarp_gain.position (0, 435); string_view.addElement (stifkarp_gain); "Gain" => ocean1_gain.name; ocean1_gain.range (0, 1); ocean1_gain.value (0.2); ocean1_gain.size (150, 75); ocean1_gain.position (200, 235); scales_view.addElement (ocean1_gain); "Gain" => rain1_gain.name; rain1_gain.range (0, 1); rain1_gain.value (1); rain1_gain.size (150, 75); rain1_gain.position (200, 335); scales_view.addElement (rain1_gain); "Gain" => rain2_gain.name; rain2_gain.range (0, 1); rain2_gain.value (0.1); rain2_gain.size (150, 75); rain2_gain.position (350, 335); scales_view.addElement (rain2_gain); Guitar.toggleType (); Guitar.size (120, 60); Guitar.position (0, 0); Guitar.name ("Guitar"); Guitar.state (1); string_view.addElement (Guitar); Flute.toggleType (); Flute.size (120, 60); Flute.position (0, 200); Flute.name ("Flute"); wind_view.addElement (Flute); Snare.toggleType (); Snare.size (120, 60); Snare.position (0, 0); Snare.name ("Snare"); percussion_view.addElement (Snare); Drum.toggleType (); Drum.size (120, 60); Drum.position (0, 100); Drum.name ("Drum"); percussion_view.addElement (Drum); Mandolin.toggleType (); Mandolin.size (120, 60); Mandolin.position (0, 200); Mandolin.name ("Mandolin"); string_view.addElement (Mandolin); Saxophone.toggleType (); Saxophone.size (120, 60); Saxophone.position (0, 0); Saxophone.name ("Saxophone"); wind_view.addElement (Saxophone); Thunder.toggleType (); Thunder.size (120, 60); Thunder.position (0, 250); Thunder.name ("Thunder"); percussion_view.addElement (Thunder); DelaySnare.toggleType (); DelaySnare.size (120, 60); DelaySnare.position (0, 350); DelaySnare.name ("Delay Snare"); percussion_view.addElement (DelaySnare); Microphone.toggleType (); Microphone.size (120, 60); Microphone.position (0, 350); Microphone.name ("Microphone"); wind_view.addElement (Microphone); Shakers.toggleType (); Shakers.size (120, 60); Shakers.position (0, 450); Shakers.name ("Shakers"); percussion_view.addElement (Shakers); StifKarp.toggleType (); StifKarp.size (120, 60); StifKarp.position (0, 400); StifKarp.name ("StifKarp"); string_view.addElement (StifKarp); WahWah.toggleType (); WahWah.size (120, 60); WahWah.position (200, 0); WahWah.name ("Wah Wah"); scales_view.addElement (WahWah); JCReverb.toggleType (); JCReverb.size (120, 60); JCReverb.position (200, 100); JCReverb.name ("JCReverb"); scales_view.addElement (JCReverb); Ocean1.toggleType (); Ocean1.size (120, 60); Ocean1.position (200, 200); Ocean1.name ("Ocean 1"); scales_view.addElement (Ocean1); Rain1.toggleType (); Rain1.size (120, 60); Rain1.position (200, 300); Rain1.name ("Rain 1"); scales_view.addElement (Rain1); Rain2.toggleType (); Rain2.size (120, 60); Rain2.position (350, 300); Rain2.name ("Rain 2"); scales_view.addElement (Rain2); M1_Dyno_limit.toggleType (); M1_Dyno_limit.size (120, 60); M1_Dyno_limit.position (550, 280); M1_Dyno_limit.name ("Limiter"); string_view.addElement (M1_Dyno_limit); M1_Dyno_compress.toggleType (); M1_Dyno_compress.size (120, 60); M1_Dyno_compress.position (650, 280); M1_Dyno_compress.name ("Compressor"); string_view.addElement (M1_Dyno_compress); M1_Dyno_expand.toggleType (); M1_Dyno_expand.size (120, 60); M1_Dyno_expand.position (550, 310); M1_Dyno_expand.name ("Expander"); string_view.addElement (M1_Dyno_expand); M1_Dyno_gate.toggleType (); M1_Dyno_gate.size (120, 60); M1_Dyno_gate.position (650, 310); M1_Dyno_gate.name ("Noise Gate"); string_view.addElement (M1_Dyno_gate); for (0 => int j; j < num_scales; j++) { scales[j].pushType (); scales[j].size (150, 60); scales[j].position (0, 50*j); if (j == 0) { scales[j].name ("lydian"); } if (j == 1) { scales[j].name ("ionian"); } if (j == 2) { scales[j].name ("mixolydian"); } if (j == 3) { scales[j].name ("dorian"); } if (j == 4) { scales[j].name ("aeolian"); } if (j == 5) { scales[j].name ("phrygian"); } if (j == 6) { scales[j].name ("locrian"); } if (j == 7) { scales[j].name ("harmonic minor"); } if (j == 8) { scales[j].name ("melodic minor"); } scales_view.addElement (scales[j]); } author.pushType (); author.size (500, 60); author.position (0, 535); author.name ("copyright 2008 Les Hall, Kijjasak Triyanond, and Pyry Pakkanen"); control_view.addElement (author); scales_view.display (); wind_view.display (); percussion_view.display (); string_view.display (); 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; 0.5 => str[i].bodySize; } } kjzGuitar101 A; // lead guitar A.output => Echo guitar_echo => LPF wahwah => JCRev jcrev => Gain master => Gain volume => WvOut wave_out => dac; 0 => master.op; // flute instrument Flute B; // many thanks to kijjaz (kijjaz@yahoo.com) for the snare code examples, rock on kijjaz! // easy white noise snare class kjzSnare101 { // note: connect output to external sources to connect Noise s => Gain s_env => LPF s_f => Gain output; // white noise source Impulse i => Gain g => Gain g_fb => g => LPF g_f => s_env; 3 => s_env.op; // make s envelope a multiplier s_f.set(3000, 4); // set default drum filter g_fb.gain(1.0 - 1.0/3000); // set default drum decay g_f.set(200, 1); // set default drum attack fun void setFilter(float f, float Q) { s_f.set(f, Q); } fun void setDecay(float decay) { g_fb.gain(1.0 - 1.0 / decay); // decay unit: samples! } fun void setAttack(float attack) { g_f.freq(attack); // attack unit: Hz! } fun void hit(float velocity) { velocity => i.next; } } kjzSnare101 C; // simple analog-sounding bass drum with pitch and amp decay and sine overdrive class kjzBD101 { Impulse i; // the attack i => Gain g1 => Gain g1_fb => g1 => LPF g1_f => Gain BDFreq; // BD pitch envelope i => Gain g2 => Gain g2_fb => g2 => LPF g2_f; // BD amp envelope // drum sound oscillator to amp envelope to overdrive to LPF to output BDFreq => SinOsc s => Gain ampenv => SinOsc s_ws => LPF s_f => Gain output; g2_f => ampenv; // amp envelope of the drum sound 3 => ampenv.op; // set ampenv a multiplier 1 => s_ws.sync; // prepare the SinOsc to be used as a waveshaper for overdrive // set default 80.0 => BDFreq.gain; // BD initial pitch: 80 hz 1.0 - 1.0 / 2000 => g1_fb.gain; // BD pitch decay g1_f.set(100, 1); // set BD pitch attack 1.0 - 1.0 / 4000 => g2_fb.gain; // BD amp decay g2_f.set(50, 1); // set BD amp attack .75 => ampenv.gain; // overdrive gain s_f.set(600, 1); // set BD lowpass filter fun void hit(float v) { v => i.next; } fun void setFreq(float f) { f => BDFreq.gain; } fun void setPitchDecay(float f) { f => g1_fb.gain; } fun void setPitchAttack(float f) { f => g1_f.freq; } fun void setDecay(float f) { f => g2_fb.gain; } fun void setAttack(float f) { f => g2_f.freq; } fun void setDriveGain(float g) { g => ampenv.gain; } fun void setFilter(float f) { f => s_f.freq; } } kjzBD101 D; // will make an arcade noise when author button is pressed kjzBD101 arcade_shot; arcade_shot.setFreq (300); arcade_shot.setPitchDecay (0.9999); arcade_shot.setPitchAttack (300); arcade_shot.setDecay (0.9999); arcade_shot.setAttack (300); arcade_shot.setDriveGain (1.0); arcade_shot.setFilter (1000); // mandolin instrument Mandolin E; Gain M1_gain => LPF M1_lpf => Dyno M1_Dyno => Gain M2_gain => Dyno M2_Dyno => master; M2_gain => FullRect rect => Gain M3_gain => LPF M2_lpf => blackhole; // wah-wah feedback M3_gain.gain (0.95); M2_Dyno.limit (); M2_lpf.set (5, 2); fun void AutoWah () { while (ms => now) { M2_lpf.last() * 1000 + 100 => M1_lpf.freq; } } spork ~ AutoWah (); // saxophone instrument Saxofony F; JCRev F_rev => master; // will chuck to F_rev later // An attempt at thunder fro kijjaz, modified by myself somewhat class kjz_thunder { // Main sound source Noise s1 => LPF f1 => Gain env1 => SinOsc overdrive1 => LPF f1_1 => NRev rev1 => Gain go; f1.set(160, .5); f1_1.set(120, .5); 3 => env1.op; 1 => overdrive1.sync; .1 => rev1.mix; .3 => rev1.gain; // Amp envelope Impulse i2 => Gain g2_1 => Gain g2_1_fb => g2_1 => Gain g2_2 => Gain g2_2_fb => g2_2 => LPF f2 => env1; f2.set(3, 1); .992 => g2_1_fb.gain => g2_2_fb.gain; 80 => f2.gain; } kjz_thunder G; LPF G_lpf => Dyno G1_limit => master; // will ChucK G.go up to this later G_lpf.freq (2000); G_lpf.gain (2); G1_limit.limit (); // Simple Delayline Snare 01 version 0.3 testing // by kijjaz // simple delaylines snare drum design: still a testing prototype // licence: Attribution-Share Alike 3.0 // You are free: // * to Share to copy, distribute and transmit the work // * to Remix to adapt the work // Under the following conditions: // * Attribution. You must attribute the work in the manner specified by the author or licensor // (but not in any way that suggests that they endorse you or your use of the work). // * Share Alike. If you alter, transform, or build upon this work, // you may distribute the resulting work only under the same, similar or a compatible license. // news: version 0.2 is never released (0.3 is developed in a different direction) // now includes a way to improve sound and flexibility from version 0.1 // and now is a class for easy integration with other programs // note: there are 4 output for you to chuck out: outputTop, outputBottom, outputTopDrive, output // output = sum of the first three outputs. warning! can be very loud // use (or set) outputLimit if you need limiting class DelaylineSnare01 { // constructing a snare drum: create top head, body, and bottom head // connect them by top -> body -> bottom -> body -> then back to top DelayA drumTop => Gain g1 => DelayA drumBody1 => Gain g2 => DelayA drumBottom => Gain g3 => DelayA drumBody2 => Gain g4 => drumTop; // prepare maximum delay time for the parts // (one second is like 315 meters in the air, i hope a snare should not be that big haha!) second => drumTop.max => drumBody1.max => drumBottom.max => drumBody2.max; // make drum top head sustain by applying feedback drumTop => Gain g5 => drumTop; // make drum bottom head sustain and attach noisy snares by AM with Noise drumBottom => Gain g6 => drumBottom; Noise snare => LPF snare_f => g6; g6.op(3); // prepare a stick and attach to Drum Top Head Impulse stickImp => LPF stickImp_f => SinOsc stickDrive => drumTop; stickDrive.sync(1); // prepare overdrive for the stick impulse Gain input => stickDrive; // chuck to input for external hitting! // prepare seperate outputs: outputTop, outputBottom, outputTopDrive drumTop => Gain outputTop; drumBottom => Gain outputBottom; drumTop => Gain drumTop_driveGain => SinOsc drumTop_drive => Gain outputTopDrive; drumTop_drive.sync(1); // prepare one master output: output, outputLimit (output with a Dyno limiter) drumTop => Gain outputTopMix => Gain output; drumBottom => Gain outputBottomMix => output; drumTop_drive => Gain outputTopDriveMix => output; output => Dyno outputLimit; outputLimit.limit(); // initialization to default sound (by using loadPreset function) loadAllValues( [200.0, 600, 1000, .3, .4, .5, .5, .6, 5, 9000, .5, 5, 180, 5, .5, .5, 1, .5], false); fun void loadAllValues(float values[], int stickDrive) { values[0] => topFreq; values[1] => bottomFreq; values[2] => bodyFreq; values[3] => topDecay; values[4] => bottomDecay; values[5] => topGain; values[6] => bottomGain; values[7] => bodyGain; values[8] => snareGain; values[9] => snareFreq; values[10] => snareQ; values[11] => stickGain; values[12] => stickFreq; values[13] => stickQ; values[14] => topDriveGain; values[15] => topMix; values[16] => bottomMix; values[17] => topDriveMix; if (stickDrive) stickDriveOn(); else stickDriveOff(); } // - - - functions - - - // drum part delay time (set by supplying frequency) fun void topFreq(float f) { second / f => drumTop.delay; } fun void bottomFreq(float f) { second / f => drumBottom.delay; } fun void bodyFreq(float f) { second / f => drumBody1.delay => drumBody1.delay; } // top and bottom decay rate fun void topDecay(float rate) { rate => g5.gain; } fun void bottomDecay(float rate) { rate => g6.gain; } fun void topGain(float g) // gain from top to body { g => g1.gain; } fun void bottomGain(float g) // gain from top to body { g => g3.gain; } fun void bodyGain(float g) // gain from body to top and bottom { g => g2.gain => g4.gain; } // snare & bottom set up fun void snareGain(float g) { g => snare.gain; } fun void snareFreq(float f) { f => snare_f.freq; } fun void snareQ(float Q) { Q => snare_f.Q; } // stick fun void stickGain(float g) { g => stickImp.gain; } fun void hit(float velocity) { velocity => stickImp.next; } fun void stickFreq(float f) { f => stickImp_f.freq; } fun void stickQ(float Q) { Q => stickImp_f.Q; } fun void stickDriveOn() // compute Sine overdrive { stickDrive.op(1); } fun void stickDriveOff() // bypass the drive unit { stickDrive.op(-1); } fun void topDriveGain(float g) // set gain for drum top overdrive { g * .5 => drumTop_driveGain.gain; } // set balance mix of each sound into the main output (and also the outputLimit) fun void topMix(float g) { g => outputTopMix.gain; } fun void bottomMix(float g) { g => outputBottomMix.gain; } fun void topDriveMix(float g) { g => outputTopDriveMix.gain; } } DelaylineSnare01 H; // the microphone input adc => Chorus mic_chorus => NRev mic_nrev => Gain microphone; // the Shakers for water drops among other sounds Shakers I; // the StifKarp for a fun guitar sound StifKarp J; // Attempt at ocean waves // copyright 2008 Les Hall // This software is protected by the GNU General Public License class ocean1 { Noise ocean_noise => LPF ocean_lpf1 => Gain output; ocean_noise => LPF ocean_lpf2 => output; } ocean1 K; // Attempt at rain sounds // copyright 2008 Les Hall // This software is protected by the GNU General Public License class Les_Rain1 { Impulse i => LPF lpf => BPF bpf => Gain output; Noise n => bpf; lpf.freq (6000); bpf.freq (15000); bpf.Q (4); n.gain (0.3); } // here comes the rain! Les_Rain1 L; // Heavy downpour from a distance class Les_Rain2 { Noise n => BPF bpf => Gain g => SinOsc osc1 => SinOsc osc2 => Gain output; bpf.freq (15000); bpf.Q (4); osc2 => g; g.gain (15000); osc1.sync (0); osc1.gain (15000); osc2.sync (0); } // here comes more rain! Les_Rain2 M; // Modedular version 0.2 testing // by Kijjasak Triyanond (kijjaz) kijjaz@yahoo.com // [note] this is still quite experimental, so some functions might have problems // some more features will be added soon. // [fixes] // * now the note function's code had been cleaned up // and is greatly reduced (in size) and optimized (generalized); the output is the same. // * i've decided that the normal rotation should not rotate the whole mode data, // but instead set the offset of the readhead while using note function // the rotation can by 'Applied' so that it really rotate the interval array. // * now chord is fully functional, check the test code to see chord in action // licence: Attribution-Share Alike 3.0 // You are free: // * to Share to copy, distribute and transmit the work // * to Remix to adapt the work // Under the following conditions: // * Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). // * Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. class Modedular { [0] @=> int intervals[]; // array of intervals in the mode 0 => int octaveSize; // octave size in semitones 0 => int rotationOffset; // for easy mode rotation fun int update() { // use this to octave Octave Size 0 => octaveSize; for(int i; i < intervals.cap(); i++) intervals[i] +=> octaveSize; return octaveSize; } fun void set(int input[]) { // use this to copy intervals from the input array new int[input.cap()] @=> intervals; for(int i; i < input.cap(); i++) input[i] => intervals[i]; update(); } fun void set(string input) { // use this to set the mode to a preset value by a string if (input == "lydian") set([2,2,2,1,2,2,1]); if (input == "ionian") set([2,2,1,2,2,2,1]); if (input == "mixolydian") set([2,2,1,2,2,1,2]); if (input == "dorian") set([2,1,2,2,2,1,2]); if (input == "aeolian") set([2,1,2,2,1,2,2]); if (input == "phrygian") set([1,2,2,2,1,2,2]); if (input == "locrian") set([1,2,2,1,2,2,2]); if (input == "harmonic minor") set([2,1,2,2,1,3,1]); if (input == "melodic minor") set([2,1,2,2,2,2,1]); update(); } fun void get(int input[]) { // use this to copy to an outside array new int[input.cap()] @=> input; for(int i; i < input.cap(); i++) intervals[i] => input[i]; } fun int note(int pitch) { // use this to acquire note (calculated in semitones) from the mode // without octave input pitch--; // so user can start the first pitch from 1 instead of 0 0 => int octave; // but we still have to use octave if pitch is negative // calculate pitch and octave for use the intervals array // by limiting pitch in rang 0..intervals.cap()-1 and adjust octave number if (pitch < 0) octave--; pitch / intervals.cap() +=> octave; (pitch - (pitch / intervals.cap() - 1) * intervals.cap()) % intervals.cap() => pitch; 0 => int sum; // calculate semitones for the pitch // with rootPosition for easy mode rotation for(int i; i < pitch; i++) intervals[(i + rotationOffset) % intervals.cap()] +=> sum; octave * octaveSize +=> sum; // select desired octave return sum; // and we'll have the result in semitone } fun int note(int pitch, int octave) { // note, with octave number also return note(pitch) + octave * octaveSize; } fun void rotate(int x) { // rotate the mode x times x +=> rotationOffset; (rotationOffset - (rotationOffset / intervals.cap() - 1) * intervals.cap()) % intervals.cap() => rotationOffset; } fun void setRotate(int x) { // reset rotation point to x x => rotationOffset; (rotationOffset - (rotationOffset / intervals.cap() - 1) * intervals.cap()) % intervals.cap() => rotationOffset; } fun void rotateApply() { // use current rotation offset to really rotate the interval array. // then reset the rotation offset. int dummy[intervals.cap()]; for(int i; i < intervals.cap(); i++) intervals[(i + rotationOffset) % intervals.cap()] => dummy[i]; for(int i; i < intervals.cap(); i++) dummy[i] => intervals[i]; 0 => rotationOffset; } fun void rotateApply(int x) { // use in supplied number as the rotation offset, then really rotate the interval array. // then reset the rotation offset, also. setRotate(x); rotateApply(); } fun void chord(int root, int positions[], int result[]) { // make a chord from position list (chord degrees) for(int i; i < positions.cap() && i < result.cap(); i++) { note(root + positions[i] - 1) => result[i]; } } fun void chord(int root, int octave, int positions[], int result[]) { // make a chord from position list, with octave for(int i; i < positions.cap() && i < result.cap(); i++) { note(root + positions[i] - 1) + octave * octaveSize => result[i]; } } } Modedular Mod; // connect to the public class Communication (in Communication.ck) master => Communication.buffer; // spork the matrix button shreds function void spork_shred_matrix () { // spork the and button shreds for (0 => int a; a < num_and_terms; a++) { for (0 => int b; b < num_digits; b++) { spork ~ and_buttons_adj (a, b); } } // spork shreds for bottom row plus and minus buttons for (0 => int b; b < num_digits; b++) { spork ~ plus_buttons_adj (b); spork ~ minus_buttons_adj (b); } // spork shreds for right side plus and minus buttons for (0 => int a; a < num_and_terms; a++) { spork ~ note_plus_buttons_adj (a); spork ~ note_minus_buttons_adj (a); } } // remove the matrix button shreds function void remove_shred_matrix () { // remove the and button shreds for (0 => int a; a < num_and_terms; a++) { for (0 => int b; b < num_digits; b++) { Machine.remove (shred_id_and_buttons[a][b]); } } // remove shreds for bottom row plus and minus buttons for (0 => int b; b < num_digits; b++) { Machine.remove (shred_id_plus_buttons[b]); Machine.remove (shred_id_minus_buttons[b]); } // remove shreds for right side plus and minus buttons for (0 => int a; a < num_and_terms; a++) { Machine.remove (shred_id_note_plus_buttons[a]); Machine.remove (shred_id_note_minus_buttons[a]); } } function void start () { while (true) { // wait for the start button to be pushed start_button.onChange () => now; if (start_button.state ()) { 1 => master.op; start_button.name ("Stop"); remove_shred_matrix (); remove_shred_scales (); } else { 0 => master.op; start_button.name ("Play"); if (record_button.state ()) { record_button.state (0); wave_out.closeFile (); } spork_shred_matrix (); spork_shred_scales (); initialize_instruments (); } } } function void record () { while (true) { // wait for the start button to be pushed record_button.onChange () => now; if (record_button.state ()) { 1 => master.op; start_button.state (1); start_button.name ("Stop"); "Guitar_Lab.wav" => wave_out.wavFilename; remove_shred_matrix (); remove_shred_scales (); } else { 0 => master.op; start_button.state (0); start_button.name ("Play"); wave_out.closeFile (); spork_shred_matrix (); spork_shred_scales (); initialize_instruments (); } } } function void clear () { while (true) { // wait for the start button to be pushed clear_button.onChange () => now; for (0 => int b; b < num_digits; b++) { 0 => j[b]; count[b].unlight (); } } } function void or_xor () { while (true) { xor_button.onChange () => now; if (xor_button.state ()) { xor_button.name ("XOR"); } else { xor_button.name ("OR"); } } } function void freq_offset_values_adj () { while (true) { freq_offset.onChange () => now; freq_offset.value () => freq_offset_values[instrument]; } } function void instrument_plus () { while (true) { instrument_plus_button.onChange () => now; if (!instrument_plus_button.state ()) { (instrument + 1) % num_instruments => instrument; change_current_instrument (); } } } function void instrument_minus () { while (true) { instrument_minus_button.onChange () => now; if (!instrument_minus_button.state ()) { if (instrument == 0) { num_instruments => instrument; } instrument - 1 => instrument; change_current_instrument (); } } } function void and_plus () { while (true) { and_plus_button.onChange () => now; if (and_plus_button.state ()) { (and_page + 1) % num_and_pages => and_page; change_current_instrument (); and_page_button.name ("page "+and_page); } } } function void and_minus () { while (true) { and_minus_button.onChange () => now; if (and_minus_button.state ()) { if (and_page == 0) { num_and_pages => and_page; } (and_page - 1) % num_and_pages => and_page; change_current_instrument (); and_page_button.name ("page "+and_page); } } } function void change_current_instrument () { if (instrument == 0) { instrument_button.name ("Guitar"); } if (instrument == 1) { instrument_button.name ("Flute"); } if (instrument == 2) { instrument_button.name ("Snare"); } if (instrument == 3) { instrument_button.name ("Drum"); } if (instrument == 4) { instrument_button.name ("Mandolin"); } if (instrument == 5) { instrument_button.name ("Saxophone"); } if (instrument == 6) { instrument_button.name ("Thunder"); } if (instrument == 7) { instrument_button.name ("Delay Snare"); } if (instrument == 8) { instrument_button.name ("Microphone"); } if (instrument == 9) { instrument_button.name ("Shakers"); } if (instrument == 10) { instrument_button.name ("StifKarp"); } for (0 => int a; a < num_and_terms; a++) { for (0 => int b; b < num_digits; b++) { if (and_values[instrument][and_page*num_and_terms+a][b] == 0) { and_buttons[a][b].name (""); } if (and_values[instrument][and_page*num_and_terms+a][b] == 1) { and_buttons[a][b].name ("1"); } if (and_values[instrument][and_page*num_and_terms+a][b] == 2) { and_buttons[a][b].name ("0"); } if (and_values[instrument][and_page*num_and_terms+a][b] == 3) { and_buttons[a][b].name ("?"); } if (and_values[instrument][and_page*num_and_terms+a][b] > 3) { 0 => and_values[instrument][a][b]; and_buttons[a][b].name (""); } } } for (0 => int b; b < num_digits; b++) { freq_buttons[b].name ("" + freq_amount[instrument][b]); } for (0 => int b; b < num_and_terms; b++) { note_buttons[b].name ("" + note[instrument][and_page][b]); } freq_offset.value (freq_offset_values[instrument]); } function void and_buttons_adj (int a, int b) { me.id () => shred_id_and_buttons[a][b]; while (true) { and_buttons[a][b].onChange () => now; 1 +=> and_values[instrument][and_page*num_and_terms+a][b]; if (and_values[instrument][and_page*num_and_terms+a][b] == 0) { and_buttons[a][b].name (""); } if (and_values[instrument][and_page*num_and_terms+a][b] == 1) { and_buttons[a][b].name ("1"); } if (and_values[instrument][and_page*num_and_terms+a][b] == 2) { and_buttons[a][b].name ("0"); } if (and_values[instrument][and_page*num_and_terms+a][b] == 3) { and_buttons[a][b].name ("?"); } if (and_values[instrument][and_page*num_and_terms+a][b] > 3) { 0 => and_values[instrument][and_page*num_and_terms+a][b]; and_buttons[a][b].name (""); } and_buttons[a][b].onChange () => now; } } function void plus_buttons_adj (int b) { me.id () => shred_id_plus_buttons[b]; while (true) { plus_buttons[b].onChange () => now; if (plus_buttons[b].state ()) { 1 +=> freq_amount[instrument][b]; freq_buttons[b].name ("" + freq_amount[instrument][b]); } } } function void minus_buttons_adj (int b) { me.id () => shred_id_minus_buttons[b]; while (true) { minus_buttons[b].onChange () => now; if (minus_buttons[b].state ()) { 1 -=> freq_amount[instrument][b]; freq_buttons[b].name ("" + freq_amount[instrument][b]); } } } function void note_plus_buttons_adj (int a) { me.id () => shred_id_note_plus_buttons[a]; while (true) { note_plus_buttons[a].onChange () => now; if (note_plus_buttons[a].state ()) { 1 +=> note[instrument][and_page][a]; note_buttons[a].name ("" + note[instrument][and_page][a]); } } } function void note_minus_buttons_adj (int a) { me.id () => shred_id_note_minus_buttons[a]; while (true) { note_minus_buttons[a].onChange () => now; if (note_minus_buttons[a].state ()) { 1 -=> note[instrument][and_page][a]; note_buttons[a].name (""+note[instrument][and_page][a]); } } } function void volume_adj () { while (true) { master_volume.onChange () => now; master_volume.value () => volume.gain; } } function void author_adj () { while (true) { author.onChange () => now; if (author.state ()) { arcade_shot.output => master; arcade_shot.hit (1.0); } else { arcade_shot.output =< master; } } } function void initialize_volume () { master_volume.value () => master.gain; } function void initialize_base () { base.value () $ int => n; } // spork insturment button shreds function void spork_shred_instruments () { spork ~ guitar_adj (); spork ~ flute_adj (); spork ~ snare_adj (); spork ~ drum_adj (); spork ~ mandolin_adj (); spork ~ saxophone_adj (); spork ~ thunder_adj (); spork ~ delaysnare_adj (); spork ~ microphone_adj (); spork ~ shakers_adj (); spork ~ stifkarp_adj (); spork ~ ocean1_adj (); spork ~ rain1_adj (); spork ~ rain2_adj (); } // guitar functions // spork guitar shreds function void spork_shred_guitar () { spork ~ guitar_gain_adj (); spork ~ reverb_adj (); spork ~ body_size_adj (); spork ~ pluck_pos_adj (); spork ~ string_damping_adj (); spork ~ string_detune_adj (); spork ~ after_touch_adj (); spork ~ guitar_echo_delay_adj (); spork ~ guitar_echo_max_adj (); spork ~ guitar_echo_mix_adj (); } // remove guitar shreds function void remove_shred_guitar () { for (0 => int i; i < num_guitar_shreds; i++) { Machine.remove (shred_id_guitar[i]); } } // adjust guitar button function void guitar_adj () { while (true) { Guitar.onChange () => now; if (Guitar.state ()) { A.output => guitar_echo; initialize_guitar (); spork_shred_guitar (); } else { A.output =< guitar_echo; remove_shred_guitar (); } } } // adjust guitar gain function void guitar_gain_adj () { me.id () => shred_id_guitar[0]; while (true) { guitar_gain.onChange () => now; A.output.gain (guitar_gain.value ()); } } // adjust guitar reverb function void reverb_adj () { me.id () => shred_id_guitar[1]; while (true) { reverb.onChange () => now; reverb.value () => A.rev.mix; } } // adjust guitar body size function void body_size_adj () { me.id () => shred_id_guitar[2]; while (true) { body_size.onChange () => now; for(int i; i < 3; i++) { body_size.value () => A.str[i].bodySize; } } } // adjust guitar pluck position function void pluck_pos_adj () { me.id () => shred_id_guitar[3]; while (true) { pluck_pos.onChange () => now; for(int i; i < 3; i++) { pluck_pos.value () => A.str[i].pluckPos; } } } // adjust guitar string damping function void string_damping_adj () { me.id () => shred_id_guitar[4]; while (true) { string_damping.onChange () => now; for(int i; i < 3; i++) { string_damping.value () => A.str[i].stringDamping; } } } // adjust guitar string detune function void string_detune_adj () { me.id () => shred_id_guitar[5]; while (true) { string_detune.onChange () => now; for(int i; i < 3; i++) { string_detune.value () => A.str[i].stringDetune; } } } // adjust guitar after touch function void after_touch_adj () { me.id () => shred_id_guitar[6]; while (true) { after_touch.onChange () => now; for(int i; i < 3; i++) { after_touch.value () => A.str[i].afterTouch; } } } // adjust guitar echo delay function void guitar_echo_delay_adj () { me.id () => shred_id_guitar[7]; while (true) { guitar_echo_delay.onChange () => now; (guitar_echo_delay.value ())::second => guitar_echo.delay; } } // adjust guitar echo max function void guitar_echo_max_adj () { me.id () => shred_id_guitar[8]; while (true) { guitar_echo_max.onChange () => now; (guitar_echo_max.value ())::second => guitar_echo.max; } } // adjust guitar echo mix function void guitar_echo_mix_adj () { me.id () => shred_id_guitar[9]; while (true) { guitar_echo_mix.onChange () => now; guitar_echo_mix.value () => guitar_echo.mix; } } // flute functions // spork flute shreds function void spork_shred_flute () { spork ~ flute_gain_adj (); spork ~ jet_delay_adj (); spork ~ jet_reflection_adj (); spork ~ end_reflection_adj (); spork ~ noise_gain_adj (); spork ~ vibrato_freq_adj (); spork ~ vibrato_gain_adj (); } // remove flute shreds function void remove_shred_flute () { for (0 => int i; i < num_flute_shreds; i++) { Machine.remove (shred_id_flute[i]); } } // adjust flute button function void flute_adj () { while (true) { Flute.onChange () => now; if (Flute.state ()) { B => wahwah; initialize_flute (); spork_shred_flute (); } else { B =< wahwah; B.noteOn (0); remove_shred_flute (); } } } // adjust flute gain function void flute_gain_adj () { me.id () => shred_id_flute[0]; while (true) { flute_gain.onChange () => now; B.gain (flute_gain.value ()); } } // adjust flute jet delay function void jet_delay_adj () { me.id () => shred_id_flute[1]; while (true) { jet_delay.onChange () => now; jet_delay.value () => B.jetDelay; } } // adjust flute jet reflection function void jet_reflection_adj () { me.id () => shred_id_flute[2]; while (true) { jet_reflection.onChange () => now; jet_reflection.value () => B.jetReflection; } } // adjust flute end reflection function void end_reflection_adj () { me.id () => shred_id_flute[3]; while (true) { end_reflection.onChange () => now; end_reflection.value () => B.endReflection; } } // adjust flute noise gain function void noise_gain_adj () { me.id () => shred_id_flute[4]; while (true) { noise_gain.onChange () => now; noise_gain.value () => B.noiseGain; } } // adjust flute vibrato frequency function void vibrato_freq_adj () { me.id () => shred_id_flute[5]; while (true) { vibrato_freq.onChange () => now; vibrato_freq.value () => B.vibratoFreq; } } // adjust flute vibrato gain function void vibrato_gain_adj () { me.id () => shred_id_flute[6]; while (true) { vibrato_gain.onChange () => now; vibrato_gain.value () => B.vibratoGain; } } // snare functions // spork snare shreds function void spork_shred_snare () { spork ~ snare_gain_adj (); spork ~ snare_freq_adj (); spork ~ snare_Q_adj (); spork ~ snare_decay_adj (); spork ~ snare_attack_adj (); } // remove snare shreds function void remove_shred_snare () { for (0 => int i; i < num_snare_shreds; i++) { Machine.remove (shred_id_snare[i]); } } // adjust snare button function void snare_adj () { while (true) { Snare.onChange () => now; if (Snare.state ()) { C.output => master; initialize_snare (); spork_shred_snare (); } else { C.output =< master; remove_shred_snare (); } } } // adjust snare gain function void snare_gain_adj () { me.id () => shred_id_snare[0]; while (true) { snare_gain.onChange () => now; C.output.gain (snare_gain.value ()); } } // adjust snare frequency function void snare_freq_adj () { me.id () => shred_id_snare[1]; while (true) { snare_freq.onChange () => now; C.setFilter (snare_freq.value (), snare_Q.value()); } } // adjust snare Q function void snare_Q_adj () { me.id () => shred_id_snare[2]; while (true) { snare_Q.onChange () => now; C.setFilter (snare_freq.value (), snare_Q.value()); } } // adjust snare decay function void snare_decay_adj () { me.id () => shred_id_snare[3]; while (true) { snare_decay.onChange () => now; C.setDecay (snare_decay.value ()); } } // adjust snare attack function void snare_attack_adj () { me.id () => shred_id_snare[4]; while (true) { snare_attack.onChange () => now; C.setAttack (snare_attack.value ()); } } // drum functions // spork drum shreds function void spork_shred_drum () { spork ~ drum_gain_adj (); spork ~ drum_freq_adj (); spork ~ drum_pitch_decay_adj (); spork ~ drum_pitch_attack_adj (); spork ~ drum_decay_adj (); spork ~ drum_attack_adj (); spork ~ drum_drive_gain_adj (); spork ~ drum_filter_adj (); } // remove drum shreds function void remove_shred_drum () { for (0 => int i; i < num_drum_shreds; i++) { Machine.remove (shred_id_drum[i]); } } // adjust drum button function void drum_adj () { while (true) { Drum.onChange () => now; if (Drum.state ()) { D.output => master; initialize_drum (); spork_shred_drum (); } else { D.output =< master; remove_shred_drum (); } } } // adjust drum gain function void drum_gain_adj () { me.id () => shred_id_drum[0]; while (true) { drum_gain.onChange () => now; D.output.gain (drum_gain.value ()); } } // adjust drum frequency function void drum_freq_adj () { me.id () => shred_id_drum[1]; while (true) { drum_freq.onChange () => now; D.setFreq (drum_freq.value ()); } } // adjust drum pitch decay function void drum_pitch_decay_adj () { me.id () => shred_id_drum[2]; while (true) { drum_pitch_decay.onChange () => now; D.setPitchDecay (drum_pitch_decay.value ()); } } // adjust drum pitch attack function void drum_pitch_attack_adj () { me.id () => shred_id_drum[3]; while (true) { drum_pitch_attack.onChange () => now; D.setPitchAttack (drum_pitch_attack.value ()); } } // adjust drum decay function void drum_decay_adj () { me.id () => shred_id_drum[4]; while (true) { drum_decay.onChange () => now; D.setDecay (drum_decay.value ()); } } // adjust drum attack function void drum_attack_adj () { me.id () => shred_id_drum[5]; while (true) { drum_attack.onChange () => now; D.setAttack (drum_attack.value ()); } } // adjust drum drive gain function void drum_drive_gain_adj () { me.id () => shred_id_drum[6]; while (true) { drum_drive_gain.onChange () => now; D.setDriveGain (drum_drive_gain.value ()); } } // adjust drum filter function void drum_filter_adj () { me.id () => shred_id_drum[7]; while (true) { drum_filter.onChange () => now; D.setFilter (drum_filter.value ()); } } // mandolin functions // spork mandolin shreds function void spork_shred_mandolin () { spork ~ mandolin_gain_adj (); spork ~ mandolin_body_size_adj (); spork ~ mandolin_pluck_pos_adj (); spork ~ mandolin_string_damping_adj (); spork ~ mandolin_string_detune_adj (); spork ~ mandolin_after_touch_adj (); spork ~ mandolin_gain1_adj (); spork ~ mandolin_gain2_adj (); spork ~ M1_Dyno_limit_adj (); spork ~ M1_Dyno_compress_adj (); spork ~ M1_Dyno_expand_adj (); spork ~ M1_Dyno_gate_adj (); } // remove mandolin shreds function void remove_shred_mandolin () { for (0 => int i; i < num_mandolin_shreds; i++) { Machine.remove (shred_id_mandolin[i]); } } // adjust mandolin button function void mandolin_adj () { while (true) { Mandolin.onChange () => now; if (Mandolin.state ()) { E => M1_gain; initialize_mandolin (); spork_shred_mandolin (); } else { E =< M1_gain; remove_shred_mandolin (); } } } // adjust manolin gain function void mandolin_gain_adj () { me.id () => shred_id_mandolin[0]; while (true) { mandolin_gain.onChange () => now; E.gain (mandolin_gain.value ()); } } // adjust mandolin body size function void mandolin_body_size_adj () { me.id () => shred_id_mandolin[1]; while (true) { mandolin_body_size.onChange () => now; E.bodySize (mandolin_body_size.value ()); } } // adjust mandolin pluck position function void mandolin_pluck_pos_adj () { me.id () => shred_id_mandolin[2]; while (true) { mandolin_pluck_pos.onChange () => now; E.pluckPos (mandolin_pluck_pos.value ()); } } // adjust mandolin string damping function void mandolin_string_damping_adj () { me.id () => shred_id_mandolin[3]; while (true) { mandolin_string_damping.onChange () => now; E.stringDamping (mandolin_string_damping.value ()); } } // adjust mandolin string detune function void mandolin_string_detune_adj () { me.id () => shred_id_mandolin[4]; while (true) { mandolin_string_detune.onChange () => now; E.stringDetune (mandolin_string_detune.value ()); } } // adjust mandolin after touch function void mandolin_after_touch_adj () { me.id () => shred_id_mandolin[5]; while (true) { mandolin_after_touch.onChange () => now; E.afterTouch (mandolin_after_touch.value ()); } } // adjust mandolin gain1 function void mandolin_gain1_adj () { me.id () => shred_id_mandolin[6]; while (true) { mandolin_gain1.onChange () => now; M1_gain.gain (mandolin_gain1.value ()); } } // adjust mandolin gain2 function void mandolin_gain2_adj () { me.id () => shred_id_mandolin[7]; while (true) { mandolin_gain2.onChange () => now; M2_gain.gain (mandolin_gain2.value ()); } } // adjust mandolin dyno limit button function void M1_Dyno_limit_adj () { me.id () => shred_id_mandolin[8]; while (true) { M1_Dyno_limit.onChange () => now; if (M1_Dyno_limit.state ()) { M1_Dyno_compress.state (0); M1_Dyno_expand.state (0); M1_Dyno_gate.state (0); M1_Dyno.limit (); } else { M1_Dyno_limit.state (1); } } } // adjust mandolin dyno compress button function void M1_Dyno_compress_adj () { me.id () => shred_id_mandolin[9]; while (true) { M1_Dyno_compress.onChange () => now; if (M1_Dyno_compress.state ()) { M1_Dyno_limit.state (0); M1_Dyno_expand.state (0); M1_Dyno_gate.state (0); M1_Dyno.compress (); } else { M1_Dyno_compress.state (1); } } } // adjust mandolin dyno expand button function void M1_Dyno_expand_adj () { me.id () => shred_id_mandolin[10]; while (true) { M1_Dyno_expand.onChange () => now; if (M1_Dyno_expand.state ()) { M1_Dyno_limit.state (0); M1_Dyno_compress.state (0); M1_Dyno_gate.state (0); M1_Dyno.expand (); } else { M1_Dyno_expand.state (1); } } } // adjust mandolin dyno gate button function void M1_Dyno_gate_adj () { me.id () => shred_id_mandolin[11]; while (true) { M1_Dyno_gate.onChange () => now; if (M1_Dyno_gate.state ()) { M1_Dyno_limit.state (0); M1_Dyno_compress.state (0); M1_Dyno_expand.state (0); M1_Dyno.gate (); } else { M1_Dyno_gate.state (1); } } } // saxophone functions function void spork_shred_saxophone () { spork ~ saxophone_gain_adj (); spork ~ saxophone_stiffness_adj (); spork ~ saxophone_aperture_adj (); spork ~ saxophone_pressure_adj (); spork ~ saxophone_noise_gain_adj (); spork ~ saxophone_vibrato_freq_adj (); spork ~ saxophone_vibrato_gain_adj (); spork ~ saxophone_blow_position_adj (); spork ~ saxophone_rate_adj (); spork ~ saxophone_reverb_adj (); } // remove saxophone shreds function void remove_shred_saxophone () { for (0 => int i; i < num_saxophone_shreds; i++) { Machine.remove (shred_id_saxophone[i]); } } // adjust saxophone button function void saxophone_adj () { while (true) { Saxophone.onChange () => now; if (Saxophone.state ()) { F => F_rev; initialize_saxophone (); spork_shred_saxophone (); } else { F =< F_rev; F.noteOff (1.0); remove_shred_saxophone (); } } } // adjust saxophone gain function void saxophone_gain_adj () { me.id () => shred_id_saxophone[0]; while (true) { saxophone_gain.onChange () => now; F.gain (saxophone_gain.value ()); } } // adjust saxophone stiffness function void saxophone_stiffness_adj () { me.id () => shred_id_saxophone[1]; while (true) { saxophone_stiffness.onChange () => now; F.stiffness (saxophone_stiffness.value ()); } } // adjust saxophone aperture function void saxophone_aperture_adj () { me.id () => shred_id_saxophone[2]; while (true) { saxophone_aperture.onChange () => now; F.stiffness (saxophone_aperture.value ()); } } // adjust saxophone pressure function void saxophone_pressure_adj () { me.id () => shred_id_saxophone[3]; while (true) { saxophone_pressure.onChange () => now; F.pressure (saxophone_pressure.value ()); } } // adjust saxophone noise gain function void saxophone_noise_gain_adj () { me.id () => shred_id_saxophone[4]; while (true) { saxophone_noise_gain.onChange () => now; F.noiseGain (saxophone_noise_gain.value ()); } } // adjust saxophone vibrato frequency function void saxophone_vibrato_freq_adj () { me.id () => shred_id_saxophone[5]; while (true) { saxophone_vibrato_freq.onChange () => now; F.vibratoFreq (saxophone_vibrato_freq.value ()); } } // adjust saxophone vibrato gain function void saxophone_vibrato_gain_adj () { me.id () => shred_id_saxophone[6]; while (true) { saxophone_vibrato_gain.onChange () => now; F.vibratoGain (saxophone_vibrato_gain.value ()); } } // adjust saxophone blow position function void saxophone_blow_position_adj () { me.id () => shred_id_saxophone[7]; while (true) { saxophone_blow_position.onChange () => now; F.blowPosition (saxophone_blow_position.value ()); } } // adjust saxophone rate function void saxophone_rate_adj () { me.id () => shred_id_saxophone[8]; while (true) { saxophone_rate.onChange () => now; F.rate (saxophone_rate.value ()); } } // adjust saxoophone reverb function void saxophone_reverb_adj () { me.id () => shred_id_saxophone[9]; while (true) { saxophone_reverb.onChange () => now; F_rev.mix (saxophone_reverb.value ()); } } // thunder functions // spork thunder shreds function void spork_shred_thunder () { spork ~ thunder_gain_adj (); } // remove thunder shreds function void remove_shred_thunder () { for (0 => int i; i < num_thunder_shreds; i++) { Machine.remove (shred_id_thunder[i]); } } // adjust thunder button function void thunder_adj () { while (true) { Thunder.onChange () => now; if (Thunder.state ()) { G.go => G_lpf; initialize_thunder (); spork_shred_thunder (); } else { G.go =< G_lpf; remove_shred_thunder (); } } } // adjust thunder gain function void thunder_gain_adj () { me.id () => shred_id_thunder[0]; while (true) { thunder_gain.onChange () => now; G.go.gain (thunder_gain.value ()); } } // delay snare functions // spork delay snare shred function void spork_shred_delaysnare () { spork ~ delaysnare_gain_adj (); } // remove delay snare shreds function void remove_shred_delaysnare () { for (0 => int i; i < num_delaysnare_shreds; i++) { Machine.remove (shred_id_delaysnare[i]); } } // adjust delay snare button function void delaysnare_adj () { while (true) { DelaySnare.onChange () => now; if (DelaySnare.state ()) { H.outputLimit => master; initialize_delaysnare (); spork_shred_delaysnare (); } else { H.outputLimit =< master; remove_shred_delaysnare (); } } } // adjust delay snare gain function void delaysnare_gain_adj () { me.id () => shred_id_delaysnare[0]; while (true) { delaysnare_gain.onChange () => now; H.outputLimit.gain (delaysnare_gain.value ()); } } // microphone functions // spork microphone shreds function void spork_shred_microphone () { spork ~ microphone_gain_adj (); spork ~ mic_chorus_mod_freq_adj (); spork ~ mic_chorus_mod_depth_adj (); spork ~ mic_chorus_mix_adj (); spork ~ mic_nrev_mix_adj (); } // remove microphone shreds function void remove_shred_mic () { for (0 => int i; i < num_mic_shreds; i++) { Machine.remove (shred_id_mic[i]); } } // adjust microphone button function void microphone_adj () { while (true) { Microphone.onChange () => now; if (Microphone.state ()) { microphone => master; initialize_microphone (); spork_shred_microphone (); } else { microphone =< master; remove_shred_mic (); } } } // adjust microphone gain function void microphone_gain_adj () { me.id () => shred_id_mic[0]; while (true) { microphone_gain.onChange () => now; microphone.gain (microphone_gain.value ()); } } // adjust microphone chorus modulation frequency function void mic_chorus_mod_freq_adj () { me.id () => shred_id_mic[1]; while (true) { mic_chorus_mod_freq.onChange () => now; mic_chorus.modFreq (mic_chorus_mod_freq.value ()); } } // adjust microphone chourus modulation depth function void mic_chorus_mod_depth_adj () { me.id () => shred_id_mic[2]; while (true) { mic_chorus_mod_depth.onChange () => now; mic_chorus.modDepth (mic_chorus_mod_depth.value ()); } } // adjust microphone chorus mix function void mic_chorus_mix_adj () { me.id () => shred_id_mic[3]; while (true) { mic_chorus_mix.onChange () => now; mic_chorus.mix (mic_chorus_mix.value ()); } } // adjust microphone nrev mix function void mic_nrev_mix_adj () { me.id () => shred_id_mic[4]; while (true) { mic_nrev_mix.onChange () => now; mic_nrev.mix (mic_nrev_mix.value ()); } } // shakers functions // spork shakers shreds function void spork_shred_shakers () { spork ~ shakers_gain_adj (); spork ~ shakers_preset_adj (); spork ~ shakers_objects_adj (); spork ~ shakers_decay_adj (); spork ~ shakers_energy_adj (); } // remove shakers shreds function void remove_shred_shakers () { for (0 => int i; i < num_shakers_shreds; i++) { Machine.remove (shred_id_shakers[i]); } } // adjust shakers button function void shakers_adj () { while (true) { Shakers.onChange () => now; if (Shakers.state ()) { I => master; initialize_shakers (); spork_shred_shakers (); } else { I =< master; remove_shred_shakers (); } } } // adjust shakers gain function void shakers_gain_adj () { me.id () => shred_id_shakers[0]; while (true) { shakers_gain.onChange () => now; I.gain (shakers_gain.value ()); } } // adjust shakers preset function void shakers_preset_adj () { me.id () => shred_id_shakers[1]; while (true) { shakers_preset.onChange () => now; I.preset (shakers_preset.value () $ int); } } // adjust shakers objects function void shakers_objects_adj () { me.id () => shred_id_shakers[2]; while (true) { shakers_objects.onChange () => now; I.objects (shakers_objects.value ()); } } // adjust shakers decay function void shakers_decay_adj () { me.id () => shred_id_shakers[3]; while (true) { shakers_decay.onChange () => now; I.decay (shakers_decay.value ()); } } // adjust shakers energy function void shakers_energy_adj () { me.id () => shred_id_shakers[4]; while (true) { shakers_energy.onChange () => now; I.energy (shakers_energy.value ()); } } // stifkarp functions // spork stifkarp shreds function void spork_shred_stifkarp () { spork ~ stifkarp_gain_adj (); spork ~ stifkarp_pickupPosition_adj (); spork ~ stifkarp_sustain_adj (); spork ~ stifkarp_stretch_adj (); spork ~ stifkarp_baseLoopGain_adj (); } // remove stifkarp shreds function void remove_shred_stifkarp () { for (0 => int i; i < num_stifkarp_shreds; i++) { Machine.remove (shred_id_stifkarp[i]); } } // adjust stifkarp button function void stifkarp_adj () { while (true) { StifKarp.onChange () => now; if (StifKarp.state ()) { J => wahwah; initialize_stifkarp (); spork_shred_stifkarp (); } else { J =< wahwah; remove_shred_stifkarp (); } } } // adjust stifkarp gain function void stifkarp_gain_adj () { me.id () => shred_id_stifkarp[0]; while (true) { stifkarp_gain.onChange () => now; J.gain (stifkarp_gain.value ()); } } // adjust stifkarp pickup position function void stifkarp_pickupPosition_adj () { me.id () => shred_id_stifkarp[1]; while (true) { stifkarp_pickupPosition.onChange () => now; J.pickupPosition (stifkarp_pickupPosition.value ()); } } // adjust stifkarp sustain function void stifkarp_sustain_adj () { me.id () => shred_id_stifkarp[2]; while (true) { stifkarp_sustain.onChange () => now; J.sustain (stifkarp_sustain.value ()); } } // adjust stifkarp stretch function void stifkarp_stretch_adj () { me.id () => shred_id_stifkarp[3]; while (true) { stifkarp_stretch.onChange () => now; J.stretch (stifkarp_stretch.value ()); } } // adjust stifkarp base loop gain function void stifkarp_baseLoopGain_adj () { me.id () => shred_id_stifkarp[4]; while (true) { stifkarp_baseLoopGain.onChange () => now; J.baseLoopGain (stifkarp_baseLoopGain.value ()); } } // ocean1 functions // spork ocean1 shreds function void spork_shred_ocean1 () { spork ~ ocean1_gain_adj (); spork ~ ocean1_lpf1_adj (); spork ~ ocean1_lpf2_adj (); } // remove ocean1 shreds function void remove_shred_ocean1 () { for (0 => int i; i < num_ocean1_shreds; i++) { Machine.remove (shred_id_ocean1[i]); } } // adjust ocean1 button function void ocean1_adj () { while (true) { Ocean1.onChange () => now; if (Ocean1.state ()) { K.output => master; initialize_ocean1 (); spork_shred_ocean1 (); } else { K.output =< master; remove_shred_ocean1 (); } } } // adjust ocean1 gain function void ocean1_gain_adj () { me.id () => shred_id_ocean1[0]; while (true) { ocean1_gain.onChange () => now; K.output.gain (ocean1_gain.value ()); } } // adjust ocean1 lpf1 function void ocean1_lpf1_adj () { me.id () => shred_id_ocean1[1]; 0 => float t; while (true) { (1 + Math.sin (2*pi * 0.1 * t) ) / 2 => float wave; K.ocean_lpf1.gain ((1 + wave) / 2); K.ocean_lpf1.freq (1000 * wave + 500); 0.001 +=> t; 1::ms => now; } } // adjust ocean1 lpf2 function void ocean1_lpf2_adj () { me.id () => shred_id_ocean1[2]; 0 => float t; while (true) { (1 + Math.cos (2*pi * 0.1 * t) ) / 2 => float wave; K.ocean_lpf2.gain ((1 + wave) / 2); K.ocean_lpf2.freq (12000 * wave + 1000); 0.001 +=> t; 1::ms => now; } } // rain1 functions // spork rain1 shreds function void spork_shred_rain1 () { spork ~ rain1_gain_adj (); spork ~ rain1_drops_adj (); } // remove rain1 shreds function void remove_shred_rain1 () { for (0 => int i; i < num_rain1_shreds; i++) { Machine.remove (shred_id_rain1[i]); } } // adjust rain1 button function void rain1_adj () { while (true) { Rain1.onChange () => now; if (Rain1.state ()) { L.lpf.freq (6000); L.bpf.freq (15000); L.bpf.Q (4); L.n.gain (0.3); L.output => master; initialize_rain1 (); spork_shred_rain1 (); } else { L.output =< master; remove_shred_rain1 (); } } } // adjust rain1 gain function void rain1_gain_adj () { me.id () => shred_id_rain1[0]; while (true) { rain1_gain.onChange () => now; L.output.gain (rain1_gain.value ()); } } // adjust rain1 drops function void rain1_drops_adj () { me.id () => shred_id_rain1[1]; while (true) { L.i.next (5*(maybe+maybe+maybe+maybe)); (maybe+maybe+maybe+maybe) * 10::ms => now; } } // rain2 functions // spork rain2 shreds function void spork_shred_rain2 () { spork ~ rain2_gain_adj (); } // remove rain2 shreds function void remove_shred_rain2 () { for (0 => int i; i < num_rain2_shreds; i++) { Machine.remove (shred_id_rain2[i]); } } // adjust rain2 button function void rain2_adj () { while (true) { Rain2.onChange () => now; if (Rain2.state ()) { M.output => master; initialize_rain2 (); spork_shred_rain2 (); } else { M.output =< master; remove_shred_rain2 (); } } } // adjust rain2 gain function void rain2_gain_adj () { me.id () => shred_id_rain1[0]; while (true) { rain2_gain.onChange () => now; M.output.gain (rain2_gain.value ()); } } // effects functions function void spork_shred_effects () { spork ~ jcreverb_mix_adj (); spork ~ wah_wah_adj (); } // remove drum shreds function void remove_shred_drum () { for (0 => int i; i < num_drum_shreds; i++) { Machine.remove (shred_id_drum[i]); } } // adjust jcreverb mix effect function void jcreverb_mix_adj () { me.id () => shred_id_effects[0]; while (true) { jcreverb_mix.onChange () => now; jcrev.mix (jcreverb_mix.value ()); } } // adjust wah wah effect function void wah_wah_adj () { me.id () => shred_id_effects[1]; 0 => float t; while (true) { wahwah.freq (4000 * (1 + Math.sin(2 * pi * wahwah_freq.value () * t)) + 1000); 0.001 +=> t; 1::ms => now; } } // scales functions // spork scales shreds function void spork_shred_scales () { for (0 => int s; s < num_scales; s++) { spork ~ scales_adj (s); } } // remove scales shreds function void remove_shred_scales () { for (0 => int s; s < num_scales; s++) { Machine.remove (shred_id_scales[s]); } } // adjust scales buttons function void scales_adj (int s) { me.id () => shred_id_scales[s]; while (true) { scales[s].onChange () => now; if (scales[s].state ()) { // change the old scale setting to lower case if (scale == 0) { scales[scale].name ("lydian"); } if (scale == 1) { scales[scale].name ("ionian"); } if (scale == 2) { scales[scale].name ("mixolydian"); } if (scale == 3) { scales[scale].name ("dorian"); } if (scale == 4) { scales[scale].name ("aeolian"); } if (scale == 5) { scales[scale].name ("phrygian"); } if (scale == 6) { scales[scale].name ("locrian"); } if (scale == 7) { scales[scale].name ("harmonic minor"); } if (scale == 8) { scales[scale].name ("melodic minor"); } // set the Modecular class scale and // change new scale setting to upper case if (s == 0) { Mod.set ("lydian"); scales[s].name ("LYDIAN"); } if (s == 1) { Mod.set ("ionian"); scales[s].name ("IONIAN"); } if (s == 2) { Mod.set ("mixolydian"); scales[s].name ("MIXOLYDIAN"); } if (s == 3) { Mod.set ("dorian"); scales[s].name ("DORIAN"); } if (s == 4) { Mod.set ("aeolian"); scales[s].name ("AEOLIAN"); } if (s == 5) { Mod.set ("phrygian"); scales[s].name ("PHRYGIAN"); } if (s == 6) { Mod.set ("locrian"); scales[s].name ("LOCRIAN"); } if (s == 7) { Mod.set ("harmonic minor"); scales[s].name ("HARMONIC MINOR"); } if (s == 8) { Mod.set ("melodic minor"); scales[s].name ("MELODIC MINOR"); } // save the scale index s => scale; } } } function void initialize_guitar () { A.output.gain (guitar_gain.value ()); reverb.value () => A.rev.mix; for(int i; i < 3; i++) { body_size.value () => A.str[i].bodySize; pluck_pos.value () => A.str[i].pluckPos; string_damping.value () => A.str[i].stringDamping; string_detune.value () => A.str[i].stringDetune; after_touch.value () => A.str[i].afterTouch; } guitar_echo.delay ((guitar_echo_delay.value ())::second); guitar_echo.max ((guitar_echo_max.value ())::second); guitar_echo.mix (guitar_echo_mix.value ()); } function void initialize_flute () { jet_delay.value () => B.jetDelay; jet_reflection.value () => B.jetReflection; end_reflection.value () => B.endReflection; noise_gain.value () => B.noiseGain; vibrato_freq.value () => B.vibratoFreq; vibrato_gain.value () => B.vibratoGain; B.gain (flute_gain.value ()); } function void initialize_snare () { C.output.gain (snare_gain.value ()); C.setFilter (snare_freq.value (), snare_Q.value()); C.setFilter (snare_freq.value (), snare_Q.value()); C.setDecay (snare_decay.value ()); C.setAttack (snare_attack.value ()); } function void initialize_drum () { D.output.gain (drum_gain.value ()); D.setFreq (drum_freq.value ()); D.setPitchDecay (drum_pitch_decay.value ()); D.setPitchAttack (drum_pitch_attack.value ()); D.setDecay (drum_decay.value ()); D.setAttack (drum_attack.value ()); D.setDriveGain (drum_drive_gain.value ()); D.setFilter (drum_filter.value ()); } function void initialize_mandolin () { E.gain (mandolin_gain.value ()); E.bodySize (mandolin_body_size.value ()); E.pluckPos (mandolin_pluck_pos.value ()); E.stringDamping (mandolin_string_damping.value ()); E.stringDetune (mandolin_string_detune.value ()); E.afterTouch (mandolin_after_touch.value ()); M1_Dyno_limit.state (1); M1_Dyno.limit (); M1_gain.gain (mandolin_gain1.value ()); M2_gain.gain (mandolin_gain2.value ()); } function void initialize_saxophone () { F.gain (saxophone_gain.value ()); F.stiffness (saxophone_stiffness.value ()); F.aperture (saxophone_aperture.value ()); F.pressure (saxophone_pressure.value ()); F.noiseGain (saxophone_noise_gain.value ()); F.vibratoFreq (saxophone_vibrato_freq.value ()); F.vibratoGain (saxophone_vibrato_gain.value ()); F.blowPosition (saxophone_blow_position.value ()); F.rate (saxophone_rate.value ()); F_rev.mix (saxophone_reverb.value ()); F.noteOff (1.0); } function void initialize_thunder () { G.go.gain (thunder_gain.value ()); } function void initialize_delaysnare () { H.outputLimit.gain (delaysnare_gain.value ()); } function void initialize_microphone () { microphone.gain (microphone_gain.value ()); mic_chorus.modFreq (mic_chorus_mod_freq.value ()); mic_chorus.modDepth (mic_chorus_mod_depth.value ()); mic_chorus.mix (mic_chorus_mix.value ()); mic_nrev.mix (mic_nrev_mix.value ()); } function void initialize_shakers () { I.gain (shakers_gain.value ()); I.preset (shakers_preset.value () $ int); I.objects (shakers_objects.value ()); I.decay (shakers_decay.value ()); I.energy (shakers_energy.value ()); } function void initialize_stifkarp () { J.gain (stifkarp_gain.value ()); J.pickupPosition (stifkarp_pickupPosition.value ()); J.sustain (stifkarp_sustain.value ()); J.stretch (stifkarp_stretch.value ()); J.baseLoopGain (stifkarp_baseLoopGain.value ()); } function void initialize_ocean1 () { K.output.gain (ocean1_gain.value ()); } function void initialize_rain1 () { L.output.gain (rain1_gain.value ()); } function void initialize_rain2 () { M.output.gain (rain2_gain.value ()); } function void initialize_effects () { wahwah.freq (20000); jcrev.mix (jcreverb_mix.value ()); } function void initialize_scales () { Mod.set ("lydian"); scales[0].name ("LYDIAN"); } function void initialize_instruments () { initialize_volume (); initialize_base (); initialize_guitar (); initialize_flute (); initialize_snare (); initialize_drum (); initialize_mandolin (); initialize_saxophone (); initialize_delaysnare (); initialize_microphone (); initialize_shakers (); initialize_stifkarp (); initialize_ocean1 (); initialize_rain1 (); initialize_rain2 (); initialize_effects (); initialize_scales (); } // initialization sporks spork ~ start (); spork ~ record (); spork ~ clear (); spork ~ or_xor (); spork ~ volume_adj (); spork ~ author_adj (); spork ~ freq_offset_values_adj (); spork ~ instrument_plus (); spork ~ instrument_minus (); spork ~ and_plus (); spork ~ and_minus (); spork_shred_matrix (); spork_shred_guitar (); spork_shred_instruments (); spork_shred_scales (); // put slider values into instruments initialize_instruments (); // count out the binary sequence and play notes while (true) { for (0 => j[11]; j[11] < n; j[11]++) { maybe => note_prob[11]; if (j[11]) {count[11].light ();} else {count[11].unlight ();} for (0 => j[10]; j[10] < n; j[10]++) { maybe => note_prob[10]; if (j[10]) {count[10].light ();} else {count[10].unlight ();} for (0 => j[9]; j[9] < n; j[9]++) { maybe => note_prob[9]; if (j[9]) {count[9].light ();} else {count[9].unlight ();} for (0 => j[8]; j[8] < n; j[8]++) { maybe => note_prob[8]; if (j[8]) {count[8].light ();} else {count[8].unlight ();} for (0 => j[7]; j[7] < n; j[7]++) { maybe => note_prob[7]; if (j[7]) {count[7].light ();} else {count[7].unlight ();} for (0 => j[6]; j[6] < n; j[6]++) { maybe => note_prob[6]; if (j[6]) {count[6].light ();} else {count[6].unlight ();} for (0 => j[5]; j[5] < n; j[5]++) { maybe => note_prob[5]; if (j[5]) {count[5].light ();} else {count[5].unlight ();} for (0 => j[4]; j[4] < n; j[4]++) { maybe => note_prob[4]; if (j[4]) {count[4].light ();} else {count[4].unlight ();} for (0 => j[3]; j[3] < n; j[3]++) { maybe => note_prob[3]; if (j[3]) {count[3].light ();} else {count[3].unlight ();} for (0 => j[2]; j[2] < n; j[2]++) { maybe => note_prob[2]; if (j[2]) {count[2].light ();} else {count[2].unlight ();} for (0 => j[1]; j[1] < n; j[1]++) { maybe => note_prob[1]; if (j[1]) {count[1].light ();} else {count[1].unlight ();} for (0 => j[0]; j[0] < n; j[0]++) { maybe => note_prob[0]; if (j[0]) {count[0].light ();} else {count[0].unlight ();} // loop thru the insruments for (0 => int i; i < num_instruments; i++) { // only calculate logic if the insturment is enabled if ( (Guitar.state () && (i == 0)) || (Flute.state () && (i == 1)) || (Snare.state () && (i == 2)) || (Drum.state () && (i == 3)) || (Mandolin.state () && (i == 4)) || (Saxophone.state () && (i == 5)) || (Thunder.state () && (i == 6)) || (DelaySnare.state () && (i == 7)) || (Shakers.state () && (i == 9)) || (StifKarp.state () && (i == 10)) ) { 0 => play_note; // initialize the note play / don't play flag 0 => freq; // initialize the frequency index // loop thru the matrix pages for (0 => int p; p < num_and_pages; p++) { // loop thru the vertical and terms for (0 => int a; a < num_and_terms; a++) { p * num_and_terms + a => page_term_index; // calculate index once to save cpu 0 => dont_care; // sete don't care total to zero 1 => and_term; // set this logic term's value to 1 // loop thru the horizontal binary digits for (0 => int b; b < num_digits; b++) { // check to see if the matrix bit is set to don't care if (and_values[i][page_term_index][b] == 0) { // increment don't care bit counter dont_care++; } // check to see if the matrix bit is set to one if (and_values[i][page_term_index][b] == 1) { // and the bit with the logic term j[b] & and_term => and_term; } // check to see if the matrix bit is set to zero if (and_values[i][page_term_index][b] == 2) { // and the inverted bit with the logic term (!j[b]) & and_term => and_term; } // check to see if the matrix bit is set to random if (and_values[i][page_term_index][b] == 3) { // and random the note probability with the logic term note_prob[b] & and_term => and_term; } } // check to see if all of the logic term bits are don't cares if (dont_care == num_digits) { 0 => and_term; // set the logic term to zero } // check to see if the XOR button is pressed if (xor_button.state ()) { // XOR the play_note with this logic term play_note ^ and_term => play_note; } else { // OR the play_note with this logic term play_note | and_term => play_note; } // check to see if the term is logic one if (and_term) { // if we are using this instrument and on the displayed page if ( (i == instrument) && (p == and_page) ) { logic[a].light (); // light the green LED for this logic term } // add the note frequency index to the frequency tally note[i][p][a] +=> freq; } else { // if we are using this instrument and on the displayed page if ( (i == instrument) && (p == and_page) ) { logic[a].unlight (); // turn off the LED for this logic term } } } } } // if this is the current active instrument if (i == instrument) { // if we are playing a note on this instrument if (play_note) { playing_note.light (); // light the blue LED } else { playing_note.unlight (); // turn off the blue LED } } // if we are playing a note if (play_note) { // loop thru all the binary digits for (0 => int b; b < num_digits; b++) { // if this bit is a one if (j[b]) { // add in the frequency contribution freq_amount[i][b] +=> freq; } } // play the guitar if (Guitar.state () && (i == 0)) { for (0 => int j; j < 3; j++) { Mod.note (freq) + freq_offset_values[i] => Std.mtof => frequency; frequency * (j+1) => A.str[j].freq; } for (0 => int j; j < 3; j++) { 0.8 - i/4.0 => A.str[j].pluck; } } // play the flute if (Flute.state () && (i == 1)) { // set the note frequency Mod.note (freq) + freq_offset_values[i] => Std.mtof => B.freq; // play the note B.noteOn (0.5); } // play the snare if (Snare.state () && (i == 2)) { // play the note C.hit (0.8); } // play the drum if (Drum.state () && (i == 3)) { // play the note D.hit (1.0); } // play the mandolin if (Mandolin.state () && (i == 4)) { // set the note frequency Mod.note (freq) + freq_offset_values[i] => Std.mtof => E.freq; // play the note E.pluck (1.0); } // play the saxophone if (Saxophone.state () && (i == 5)) { // set the note frequency Mod.note (freq) + freq_offset_values[i] => Std.mtof => F.freq; // play the note F.noteOn (1.0); } // play the thunder if (Thunder.state () && (i == 6)) { // set the gain as a function of frequency G.go.gain(thunder_gain.value () * freq); // check to see if thunder happens this time if (Std.rand2f(0,1) <= thunder_probability.value ()) { // play the thunder G.i2.next (1); } } // play the delay snare if (DelaySnare.state () && (i == 7)) { // loop thru the delay model parameter for(0 => int j; j < 4; j++) { // play the note H.hit(j + 1 + freq); } } // play the shakers if (Shakers.state () && (i == 9)) { // set the note frequency Mod.note (freq) + freq_offset_values[i] => Std.mtof => I.freq; // play the note I.noteOn (1.0); } // pjay the StifKarp if (StifKarp.state () && (i == 10)) { // set the note frequency Mod.note (freq) + freq_offset_values[i] => Std.mtof => J.freq; // play the note J.pluck (1.0); } } } // infinite loop here if start button is not pressed while (!start_button.state ()) { 100::ms => now; } // advance time, and do it quickly if ffwd button is pressed if (ffwd_button.state ()) { 16 => playback_rate; } else { 1 => playback_rate; } 1::second / (playback_rate * notes_per_second.value ()) => now; } } } } } } } } } } } } }