// 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 int freq; // the frequency index of the next note float frequency; // 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 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 [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 float note_prob[num_digits]; // the note probability for each bit position 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, 100); master_volume.value (50); master_volume.size (200, 75); master_volume.position (550, 425); master_volume.displayFormat (master_volume.integerFormat); control_view.addElement (master_volume); "Base" => base.name; base.range (2, 10); base.value (2); base.size (200, 75); base.position (550, 475); 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 (200, 75); freq_offset.position (300, 525); freq_offset.displayFormat (freq_offset.integerFormat); control_view.addElement (freq_offset); "Notes per Second" => notes_per_second.name; notes_per_second.range (1, 16); notes_per_second.value (6); notes_per_second.size (200, 75); notes_per_second.position (550, 525); 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].toggleType (); 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 (250, 60); author.position (0, 535); author.name ("copyright 2008 Les Hall and kijjaz"); 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; 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"); } else { 0 => master.op; start_button.name ("Play"); if (record_button.state ()) { record_button.state (0); wave_out.closeFile (); } } } } 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; } else { 0 => master.op; start_button.state (0); start_button.name ("Play"); wave_out.closeFile (); } } } 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) { 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) { while (true) { plus_buttons[b].onChange () => now; 1 +=> freq_amount[instrument][b]; freq_buttons[b].name ("" + freq_amount[instrument][b]); plus_buttons[b].onChange () => now; } } function void minus_buttons_adj (int b) { while (true) { minus_buttons[b].onChange () => now; 1 -=> freq_amount[instrument][b]; freq_buttons[b].name ("" + freq_amount[instrument][b]); minus_buttons[b].onChange () => now; } } function void note_plus_buttons_adj (int b) { while (true) { note_plus_buttons[b].onChange () => now; 1 +=> note[instrument][and_page][b]; note_buttons[b].name ("" + note[instrument][and_page][b]); note_plus_buttons[b].onChange () => now; } } function void note_minus_buttons_adj (int b) { while (true) { note_minus_buttons[b].onChange () => now; 1 -=> note[instrument][and_page][b]; note_buttons[b].name (""+note[instrument][and_page][b]); note_minus_buttons[b].onChange () => now; } } function void volume_adj () { while (true) { // wait for the volume slider to be changed master_volume.onChange () => now; master_volume.value () / 100.0 => volume.gain; } } function void base_adj () { while (true) { base.onChange () => now; base.value () $ int => n; } } function void reverb_adj () { while (true) { reverb.onChange () => now; reverb.value () => A.rev.mix; } } function void body_size_adj () { while (true) { body_size.onChange () => now; for(int i; i < 3; i++) { body_size.value () => A.str[i].bodySize; } } } function void pluck_pos_adj () { while (true) { pluck_pos.onChange () => now; for(int i; i < 3; i++) { pluck_pos.value () => A.str[i].pluckPos; } } } function void string_damping_adj () { while (true) { string_damping.onChange () => now; for(int i; i < 3; i++) { string_damping.value () => A.str[i].stringDamping; } } } function void string_detune_adj () { while (true) { string_detune.onChange () => now; for(int i; i < 3; i++) { string_detune.value () => A.str[i].stringDetune; } } } function void after_touch_adj () { while (true) { after_touch.onChange () => now; for(int i; i < 3; i++) { after_touch.value () => A.str[i].afterTouch; } } } function void guitar_echo_delay_adj () { while (true) { guitar_echo_delay.onChange () => now; (guitar_echo_delay.value ())::second => guitar_echo.delay; } } function void guitar_echo_max_adj () { while (true) { guitar_echo_max.onChange () => now; (guitar_echo_max.value ())::second => guitar_echo.max; } } function void guitar_echo_mix_adj () { while (true) { guitar_echo_mix.onChange () => now; guitar_echo_mix.value () => guitar_echo.mix; } } function void jet_delay_adj () { while (true) { jet_delay.onChange () => now; jet_delay.value () => B.jetDelay; } } function void jet_reflection_adj () { while (true) { jet_reflection.onChange () => now; jet_reflection.value () => B.jetReflection; } } function void end_reflection_adj () { while (true) { end_reflection.onChange () => now; end_reflection.value () => B.endReflection; } } function void noise_gain_adj () { while (true) { noise_gain.onChange () => now; noise_gain.value () => B.noiseGain; } } function void vibrato_freq_adj () { while (true) { vibrato_freq.onChange () => now; vibrato_freq.value () => B.vibratoFreq; } } function void vibrato_gain_adj () { while (true) { vibrato_gain.onChange () => now; vibrato_gain.value () => B.vibratoGain; } } function void snare_freq_adj () { while (true) { snare_freq.onChange () => now; C.setFilter (snare_freq.value (), snare_Q.value()); } } function void snare_Q_adj () { while (true) { snare_Q.onChange () => now; C.setFilter (snare_freq.value (), snare_Q.value()); } } function void snare_decay_adj () { while (true) { snare_decay.onChange () => now; C.setDecay (snare_decay.value ()); } } function void snare_attack_adj () { while (true) { snare_attack.onChange () => now; C.setAttack (snare_attack.value ()); } } function void drum_freq_adj () { while (true) { drum_freq.onChange () => now; D.setFreq (drum_freq.value ()); } } function void drum_pitch_decay_adj () { while (true) { drum_pitch_decay.onChange () => now; D.setPitchDecay (drum_pitch_decay.value ()); } } function void drum_pitch_attack_adj () { while (true) { drum_pitch_attack.onChange () => now; D.setPitchAttack (drum_pitch_attack.value ()); } } function void drum_decay_adj () { while (true) { drum_decay.onChange () => now; D.setDecay (drum_decay.value ()); } } function void drum_attack_adj () { while (true) { drum_attack.onChange () => now; D.setAttack (drum_attack.value ()); } } function void drum_drive_gain_adj () { while (true) { drum_drive_gain.onChange () => now; D.setDriveGain (drum_drive_gain.value ()); } } function void drum_filter_adj () { while (true) { drum_filter.onChange () => now; D.setFilter (drum_filter.value ()); } } function void mandolin_body_size_adj () { while (true) { mandolin_body_size.onChange () => now; E.bodySize (mandolin_body_size.value ()); } } function void mandolin_pluck_pos_adj () { while (true) { mandolin_pluck_pos.onChange () => now; E.pluckPos (mandolin_pluck_pos.value ()); } } function void mandolin_string_damping_adj () { while (true) { mandolin_string_damping.onChange () => now; E.stringDamping (mandolin_string_damping.value ()); } } function void mandolin_string_detune_adj () { while (true) { mandolin_string_detune.onChange () => now; E.stringDetune (mandolin_string_detune.value ()); } } function void mandolin_after_touch_adj () { while (true) { mandolin_after_touch.onChange () => now; E.afterTouch (mandolin_after_touch.value ()); } } function void mandolin_gain1_adj () { while (true) { mandolin_gain1.onChange () => now; M1_gain.gain (mandolin_gain1.value ()); } } function void mandolin_gain2_adj () { while (true) { mandolin_gain2.onChange () => now; M2_gain.gain (mandolin_gain2.value ()); } } function void saxophone_stiffness_adj () { while (true) { saxophone_stiffness.onChange () => now; F.stiffness (saxophone_stiffness.value ()); } } function void saxophone_aperture_adj () { while (true) { saxophone_aperture.onChange () => now; F.stiffness (saxophone_aperture.value ()); } } function void saxophone_pressure_adj () { while (true) { saxophone_pressure.onChange () => now; F.pressure (saxophone_pressure.value ()); } } function void saxophone_noise_gain_adj () { while (true) { saxophone_noise_gain.onChange () => now; F.noiseGain (saxophone_noise_gain.value ()); } } function void saxophone_vibrato_freq_adj () { while (true) { saxophone_vibrato_freq.onChange () => now; F.vibratoFreq (saxophone_vibrato_freq.value ()); } } function void saxophone_vibrato_gain_adj () { while (true) { saxophone_vibrato_gain.onChange () => now; F.vibratoGain (saxophone_vibrato_gain.value ()); } } function void saxophone_blow_position_adj () { while (true) { saxophone_blow_position.onChange () => now; F.blowPosition (saxophone_blow_position.value ()); } } function void saxophone_rate_adj () { while (true) { saxophone_rate.onChange () => now; F.rate (saxophone_rate.value ()); } } function void saxophone_reverb_adj () { while (true) { saxophone_reverb.onChange () => now; F_rev.mix (saxophone_reverb.value ()); } } function void mic_chorus_mod_freq_adj () { while (true) { mic_chorus_mod_freq.onChange () => now; mic_chorus.modFreq (mic_chorus_mod_freq.value ()); } } function void mic_chorus_mod_depth_adj () { while (true) { mic_chorus_mod_depth.onChange () => now; mic_chorus.modDepth (mic_chorus_mod_depth.value ()); } } function void mic_chorus_mix_adj () { while (true) { mic_chorus_mix.onChange () => now; mic_chorus.mix (mic_chorus_mix.value ()); } } function void mic_nrev_mix_adj () { while (true) { mic_nrev_mix.onChange () => now; mic_nrev.mix (mic_nrev_mix.value ()); } } function void shakers_preset_adj () { while (true) { shakers_preset.onChange () => now; I.preset (shakers_preset.value () $ int); } } function void shakers_objects_adj () { while (true) { shakers_objects.onChange () => now; I.objects (shakers_objects.value ()); } } function void shakers_decay_adj () { while (true) { shakers_decay.onChange () => now; I.decay (shakers_decay.value ()); } } function void shakers_energy_adj () { while (true) { shakers_energy.onChange () => now; I.energy (shakers_energy.value ()); } } function void stifkarp_pickupPosition_adj () { while (true) { stifkarp_pickupPosition.onChange () => now; J.pickupPosition (stifkarp_pickupPosition.value ()); } } function void stifkarp_sustain_adj () { while (true) { stifkarp_sustain.onChange () => now; J.sustain (stifkarp_sustain.value ()); } } function void stifkarp_stretch_adj () { while (true) { stifkarp_stretch.onChange () => now; J.stretch (stifkarp_stretch.value ()); } } function void stifkarp_baseLoopGain_adj () { while (true) { stifkarp_baseLoopGain.onChange () => now; J.baseLoopGain (stifkarp_baseLoopGain.value ()); } } function void jcreverb_mix_adj () { while (true) { jcreverb_mix.onChange () => now; jcrev.mix (jcreverb_mix.value ()); } } function void guitar_gain_adj () { while (true) { guitar_gain.onChange () => now; A.output.gain (guitar_gain.value ()); } } function void flute_gain_adj () { while (true) { flute_gain.onChange () => now; B.gain (flute_gain.value ()); } } function void snare_gain_adj () { while (true) { snare_gain.onChange () => now; C.output.gain (snare_gain.value ()); } } function void drum_gain_adj () { while (true) { drum_gain.onChange () => now; D.output.gain (drum_gain.value ()); } } function void mandolin_gain_adj () { while (true) { mandolin_gain.onChange () => now; E.gain (mandolin_gain.value ()); } } function void saxophone_gain_adj () { while (true) { saxophone_gain.onChange () => now; F.gain (saxophone_gain.value ()); } } function void delaysnare_gain_adj () { while (true) { delaysnare_gain.onChange () => now; H.outputLimit.gain (delaysnare_gain.value ()); } } function void microphone_gain_adj () { while (true) { microphone_gain.onChange () => now; microphone.gain (microphone_gain.value ()); } } function void stifkarp_gain_adj () { while (true) { stifkarp_gain.onChange () => now; J.gain (stifkarp_gain.value ()); } } function void scales_adj (int a) { while (true) { scales[a].onChange () => now; for (0 => int j; j < num_scales; j++) { if (j != a) { scales[j].state (0); } else { scales[j].state (1); } } if (a == 0) { Mod.set ("lydian"); } if (a == 1) { Mod.set ("ionian"); } if (a == 2) { Mod.set ("mixolydian"); } if (a == 3) { Mod.set ("dorian"); } if (a == 4) { Mod.set ("aeolian"); } if (a == 5) { Mod.set ("phrygian"); } if (a == 6) { Mod.set ("locrian"); } if (a == 7) { Mod.set ("harmonic minor"); } if (a == 8) { Mod.set ("melodic minor"); } } } function void guitar_adj () { while (true) { Guitar.onChange () => now; if (Guitar.state ()) { A.output => guitar_echo; } else { A.output =< guitar_echo; } } } function void flute_adj () { while (true) { Flute.onChange () => now; if (Flute.state ()) { B => wahwah; } else { B =< wahwah; B.noteOn (0); } } } function void snare_adj () { while (true) { Snare.onChange () => now; if (Snare.state ()) { C.output => master; } else { C.output =< master; } } } function void drum_adj () { while (true) { Drum.onChange () => now; if (Drum.state ()) { D.output => master; } else { D.output =< master; } } } function void mandolin_adj () { while (true) { Mandolin.onChange () => now; if (Mandolin.state ()) { E => M1_gain; } else { E =< M1_gain; } } } function void saxophone_adj () { while (true) { Saxophone.onChange () => now; if (Saxophone.state ()) { F => F_rev; } else { F =< F_rev; F.noteOff (1.0); } } } function void thunder_adj () { while (true) { Thunder.onChange () => now; if (Thunder.state ()) { G.go => G_lpf; } else { G.go =< G_lpf; } } } function void delaysnare_adj () { while (true) { DelaySnare.onChange () => now; if (DelaySnare.state ()) { H.outputLimit => master; } else { H.outputLimit =< master; } } } function void microphone_adj () { while (true) { Microphone.onChange () => now; if (Microphone.state ()) { microphone => master; } else { microphone =< master; } } } function void shakers_adj () { while (true) { Shakers.onChange () => now; if (Shakers.state ()) { I => master; } else { I =< master; } } } function void stifkarp_adj () { while (true) { StifKarp.onChange () => now; if (StifKarp.state ()) { J => wahwah; } else { J =< wahwah; } } } 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 M1_Dyno_limit_adj () { 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); } } } function void M1_Dyno_compress_adj () { 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); } } } function void M1_Dyno_expand_adj () { 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); } } } function void M1_Dyno_gate_adj () { 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); } } } function void wah_wah_adj () { 0 => float t; while (true) { if (WahWah.state ()) { wahwah.freq (4000 * (1 + Math.sin(2 * pi * wahwah_freq.value () * t)) + 1000); } else { wahwah.freq (20000); } 0.001 +=> t; 1::ms => now; } } function void ocean1_gain_adj () { while (true) { ocean1_gain.onChange () => now; K.output.gain (ocean1_gain.value ()); } } function void ocean1_adj () { while (true) { Ocean1.onChange () => now; if (Ocean1.state ()) { K.output => master; } else { K.output =< master; } } } function void ocean_lpf1_adj () { 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; } } function void ocean_lpf2_adj () { 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; } } function void rain1_gain_adj () { while (true) { rain1_gain.onChange () => now; L.output.gain (rain1_gain.value ()); } } 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; } else { L.output =< master; } } } function void rain1_drops_adj () { while (true) { L.i.next (5*(maybe+maybe+maybe+maybe)); (maybe+maybe+maybe+maybe) * 10::ms => now; } } function void rain2_gain_adj () { while (true) { rain2_gain.onChange () => now; M.output.gain (rain2_gain.value ()); } } function void rain2_adj () { while (true) { Rain2.onChange () => now; if (Rain2.state ()) { M.output => master; } else { M.output =< master; } } } function void initialize_instruments () { master_volume.value () / 100.0 => master.gain; base.value () $ int => n; 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 ()); 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; 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 ()); 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 ()); 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 ()); 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 ()); H.outputLimit.gain (delaysnare_gain.value ()); 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 ()); I.preset (shakers_preset.value () $ int); I.objects (shakers_objects.value ()); I.decay (shakers_decay.value ()); I.energy (shakers_energy.value ()); 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 ()); K.output.gain (ocean1_gain.value ()); wahwah.freq (20000); jcrev.mix (jcreverb_mix.value ()); A.output.gain (guitar_gain.value ()); B.gain (flute_gain.value ()); C.output.gain (snare_gain.value ()); D.output.gain (drum_gain.value ()); E.gain (mandolin_gain.value ()); F.gain (saxophone_gain.value ()); F.noteOff (1.0); scales[0].state (1); Mod.set ("lydian"); M1_Dyno_limit.state (1); M1_Dyno.limit (); M1_gain.gain (mandolin_gain1.value ()); M2_gain.gain (mandolin_gain2.value ()); L.output.gain (rain1_gain.value ()); M.output.gain (rain2_gain.value ()); } spork ~ start (); spork ~ record (); spork ~ clear (); spork ~ or_xor (); spork ~ freq_offset_values_adj (); spork ~ instrument_plus (); spork ~ instrument_minus (); for (0 => int b; b < num_digits; b++) { spork ~ plus_buttons_adj (b); spork ~ minus_buttons_adj (b); } for (0 => int b; b < num_and_terms; b++) { spork ~ note_plus_buttons_adj (b); spork ~ note_minus_buttons_adj (b); } for (0 => int a; a < num_and_terms; a++) { for (0 => int b; b < num_digits; b++) { spork ~ and_buttons_adj (a, b); } } spork ~ volume_adj (); spork ~ base_adj (); spork ~ and_plus (); spork ~ and_minus (); 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 (); spork ~ jet_delay_adj (); spork ~ jet_reflection_adj (); spork ~ end_reflection_adj (); spork ~ noise_gain_adj (); spork ~ vibrato_freq_adj (); spork ~ vibrato_gain_adj (); spork ~ snare_freq_adj (); spork ~ snare_Q_adj (); spork ~ snare_decay_adj (); spork ~ snare_attack_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 (); 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 ~ 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 (); spork ~ mic_chorus_mod_freq_adj (); spork ~ mic_chorus_mod_depth_adj (); spork ~ mic_chorus_mix_adj (); spork ~ mic_nrev_mix_adj (); spork ~ shakers_preset_adj (); spork ~ shakers_objects_adj (); spork ~ shakers_decay_adj (); spork ~ shakers_energy_adj (); spork ~ stifkarp_pickupPosition_adj (); spork ~ stifkarp_sustain_adj (); spork ~ stifkarp_stretch_adj (); spork ~ stifkarp_baseLoopGain_adj (); spork ~ jcreverb_mix_adj (); spork ~ guitar_gain_adj (); spork ~ flute_gain_adj (); spork ~ snare_gain_adj (); spork ~ drum_gain_adj (); spork ~ mandolin_gain_adj (); spork ~ saxophone_gain_adj (); spork ~ delaysnare_gain_adj (); spork ~ microphone_gain_adj (); spork ~ stifkarp_gain_adj (); 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 ~ author_adj (); spork ~ M1_Dyno_limit_adj (); spork ~ M1_Dyno_compress_adj (); spork ~ M1_Dyno_expand_adj (); spork ~ M1_Dyno_gate_adj (); for (0 => int a; a < num_scales; a++) { spork ~ scales_adj (a); } spork ~ wah_wah_adj (); spork ~ ocean1_gain_adj (); spork ~ ocean1_adj (); spork ~ ocean_lpf1_adj (); spork ~ ocean_lpf2_adj (); spork ~ rain1_gain_adj (); spork ~ rain1_adj (); spork ~ rain1_drops_adj (); spork ~ rain2_gain_adj (); spork ~ rain2_adj (); // 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]; for (0 => j[10]; j[10] < n; j[10]++) { maybe => note_prob[10]; for (0 => j[9]; j[9] < n; j[9]++) { maybe => note_prob[9]; for (0 => j[8]; j[8] < n; j[8]++) { maybe => note_prob[8]; for (0 => j[7]; j[7] < n; j[7]++) { maybe => note_prob[7]; for (0 => j[6]; j[6] < n; j[6]++) { maybe => note_prob[6]; for (0 => j[5]; j[5] < n; j[5]++) { maybe => note_prob[5]; for (0 => j[4]; j[4] < n; j[4]++) { maybe => note_prob[4]; for (0 => j[3]; j[3] < n; j[3]++) { maybe => note_prob[3]; for (0 => j[2]; j[2] < n; j[2]++) { maybe => note_prob[2]; for (0 => j[1]; j[1] < n; j[1]++) { maybe => note_prob[1]; for (0 => j[0]; j[0] < n; j[0]++) { maybe => note_prob[0]; for (0 => int b; b < num_digits; b++) { if (j[b]) { count[b].light (); } else { count[b].unlight (); } } for (0 => int i; i < num_instruments; i++) { 0 => freq; 0 => play_note; 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)) ) { for (0 => int p; p < num_and_pages; p++) { 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_values[i][p*num_and_terms+a][b] == 1) { if (j[b]) { 1 +=> and_term; } 1 +=> and_bits; } if (and_values[i][p*num_and_terms+a][b] == 2) { if (!j[b]) { 1 +=> and_term; } 1 +=> and_bits; } if (and_values[i][p*num_and_terms+a][b] == 3) { if (note_prob[b]) { 1 +=> and_term; } 1 +=> and_bits; } } if ( (and_term == and_bits) && (and_bits > 0) ) { if (xor_button.state ()) { play_note ^ 1 => play_note; } else { 1 => play_note; } if ( (i == instrument) && (p == and_page) ) { logic[a].light (); } note[i][p][a] +=> freq; } else { if ( (i == instrument) && (p == and_page) ) { logic[a].unlight (); } } } } } // light up the blue playing_note light if (i == instrument) { if (play_note) { playing_note.light (); } else { playing_note.unlight (); } } if (play_note) { for (0 => int b; b < num_digits; b++) { j[b]*freq_amount[i][b] +=> freq; } 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; } } if (Flute.state () && (i == 1)) { Mod.note (freq) + freq_offset_values[i] => Std.mtof => B.freq; B.noteOn (0.5); } if (Snare.state () && (i == 2)) { C.hit (0.8); } if (Drum.state () && (i == 3)) { D.hit (1.0); } if (Mandolin.state () && (i == 4)) { Mod.note (freq) + freq_offset_values[i] => Std.mtof => E.freq; E.pluck (1.0); } if (Saxophone.state () && (i == 5)) { Mod.note (freq) + freq_offset_values[i] => Std.mtof => F.freq; F.noteOn (1.0); } if (Thunder.state () && (i == 6)) { G.go.gain(thunder_gain.value () * freq); if (Std.rand2(0,1) <= thunder_probability.value ()) { G.i2.next (1); } } if (DelaySnare.state () && (i == 7)) { for(int j; j < 4; j++) { H.hit(j + 1 + freq); } } if (Shakers.state () && (i == 9)) { Mod.note (freq) + freq_offset_values[i] => Std.mtof => I.freq; I.noteOn (1.0); } if (StifKarp.state () && (i == 10)) { Mod.note (freq) + freq_offset_values[i] => Std.mtof => J.freq; J.pluck (1.0); } } } // infinite loop here if start button is not pressed while (!start_button.state ()) { 100::ms => now; for (0 => int a; a < num_and_terms; a++) { logic[a].unlight (); } playing_note.unlight (); } // advance time, and do it quickly if ffwd button is pressed if (ffwd_button.state ()) { 1::second / (16 * notes_per_second.value ()) => now; } else { 1::second / notes_per_second.value () => now; } } } } } } } } } } } } } }