{"commit":"44476b319bc6149820ab86b6330c932aa6948924","subject":"changed midi ccs to osc.","message":"changed midi ccs to osc.\n","repos":"jordanorelli\/wii-chuck-synth","old_file":"resin_run.ck","new_file":"resin_run.ck","new_contents":"OscRecv wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float rawGain;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\/\/ ToneCalc.grid(8, 8, 1, 5, 82.4068867, 12.0) @=> float toneMap[][];\nToneCalc.grid(8, 8, 1, 5, 55.0, 12.0) @=> float toneMap[][];\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 55.0, 12.0) @=> oscBank;\n\n if(prompt)\n {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n\n Launchpad.Launchpad(lpChannel) @=> lp;\n }\n else\n {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone)\n {\n return;\n }\n\n if(toneChoice == 0)\n {\n oscBank.setPatch(\"SinOsc\");\n }\n else if(toneChoice == 1)\n {\n oscBank.setPatch(\"SqrOsc\");\n }\n else if(toneChoice == 2)\n {\n oscBank.setPatch(\"SawOsc\");\n }\n else if(toneChoice == 3)\n {\n oscBank.setPatch(\"TriOsc\");\n }\n else\n {\n return;\n }\n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void sostenutoOn()\n{\n true => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sostenutoStatus[i][j];\n }\n }\n }\n}\n\nfun void sostenutoOff()\n{\n false => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sostenutoStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void sustainOn()\n{\n true => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sustainStatus[i][j];\n }\n }\n }\n}\n\nfun void sustainOff()\n{\n false => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sustainStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n rawGain => targetGain;\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\n\/\/ fun void wiiParser(MidiMsg msg)\n\/\/ {\n\/\/ if(msg.data1 == 176) \/\/ midi CC\n\/\/ {\n\/\/ if(msg.data2 == 64)\n\/\/ { \/\/ wiimote acceleration\n\/\/ msg.data3 => rawGain;\n\/\/ }\n\/\/ else if (msg.data2 == 65)\n\/\/ { \/\/ wiimote button b\n\/\/ if(msg.data3 == 127)\n\/\/ {\n\/\/ sustainOn();\n\/\/ }\n\/\/ else\n\/\/ {\n\/\/ sustainOff();\n\/\/ }\n\/\/ }\n\/\/ else if (msg.data2 == 66)\n\/\/ { \/\/ wiimote button a\n\/\/ if(msg.data3 == 127)\n\/\/ {\n\/\/ sostenutoOn();\n\/\/ }\n\/\/ else\n\/\/ {\n\/\/ sostenutoOff();\n\/\/ }\n\/\/ }\n\/\/ }\n\/\/ }\n\nfun void sustainListener()\n{\n wm.event(\"\/wii\/1\/button\/B,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sustainOff();\n }\n else\n {\n sustainOn();\n }\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sostenutoOff();\n }\n else\n {\n sostenutoOn();\n }\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n e.getFloat() => rawGain;\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true)\n {\n 1::second => now;\n }\n}\n\nsetup();\n\nwhile(true)\n{\n 100::ms => now;\n}\n","old_contents":"MidiIn wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0 => int rawGain;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n1 => int wiimoteChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\/\/ ToneCalc.grid(8, 8, 1, 5, 82.4068867, 12.0) @=> float toneMap[][];\nToneCalc.grid(8, 8, 1, 5, 55.0, 12.0) @=> float toneMap[][];\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 55.0, 12.0) @=> oscBank;\n\n if(prompt)\n {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n intPrompt(\"Enter Midi Channel for Wiimote input: \") => wiimoteChannel;\n\n Launchpad.Launchpad(lpChannel) @=> lp;\n connectWiimote(wiimoteChannel);\n }\n else\n {\n Launchpad.Launchpad(0) @=> lp;\n connectWiimote(1);\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone)\n {\n return;\n }\n\n if(toneChoice == 0)\n {\n oscBank.setPatch(\"SinOsc\");\n }\n else if(toneChoice == 1)\n {\n oscBank.setPatch(\"SqrOsc\");\n }\n else if(toneChoice == 2)\n {\n oscBank.setPatch(\"SawOsc\");\n }\n else if(toneChoice == 3)\n {\n oscBank.setPatch(\"TriOsc\");\n }\n else\n {\n return;\n }\n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void sostenutoOn()\n{\n true => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sostenutoStatus[i][j];\n }\n }\n }\n}\n\nfun void sostenutoOff()\n{\n false => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sostenutoStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void sustainOn()\n{\n true => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sustainStatus[i][j];\n }\n }\n }\n}\n\nfun void sustainOff()\n{\n false => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sustainStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\nfun void wiiParser(MidiMsg msg)\n{\n if(msg.data1 == 176) \/\/ midi CC\n {\n if(msg.data2 == 64)\n { \/\/ wiimote acceleration\n msg.data3 => rawGain;\n }\n else if (msg.data2 == 65)\n { \/\/ wiimote button b\n if(msg.data3 == 127)\n {\n sustainOn();\n }\n else\n {\n sustainOff();\n }\n }\n else if (msg.data2 == 66)\n { \/\/ wiimote button a\n if(msg.data3 == 127)\n {\n sostenutoOn();\n }\n else\n {\n sostenutoOff();\n }\n }\n }\n}\n\nfun void connectWiimote(int midiChannel)\n{\n if(!wm.open(midiChannel)) me.exit();\n\n chout <= \"Midi device: \" <= midiChannel <= \" -> \" <= wm.name()\n <= IO.newline();\n}\n\nfun void wiiListener()\n{\n MidiMsg msg;\n while(true)\n {\n wm => now;\n while(wm.recv(msg))\n {\n wiiParser(msg);\n }\n }\n}\n\nsetup();\n\nwhile(true)\n{\n 100::ms => now;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"a242be285fb3f3bfade3e216683152c5ea4b9411","subject":"Update bassdrum_electronic_deepboom.ck","message":"Update bassdrum_electronic_deepboom.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electronic_deepboom.ck","new_file":"patches\/percussion\/bassdrum_electronic_deepboom.ck","new_contents":"public class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 310, -.98, 1.0,50,-.6, 11.0, 1.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 621::ms, 0.0, 135::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 181::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n SinOsc form => volE => LPF boom => PoleZero dc => bdmast; \n dc.blockZero(0.992);\n 70 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(1.3);\n 41::samp => now;\n\n \/\/ advance time\n if (now > (start + 170::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\n\/\/KickSynC kick1;\n\n\/\/kick1.bdmast => dac;\n\/\/kick1.trigger(1.3);\n\n\/\/1::second => now;\n\n","old_contents":"\/\/ Assignment 7 drumCircleDSP\npublic class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 310, -.98, 1.0,50,-.6, 11.0, 1.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 621::ms, 0.0, 135::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 181::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n SinOsc form => volE => LPF boom => PoleZero dc => bdmast; \n dc.blockZero(0.992);\n 70 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(1.3);\n 41::samp => now;\n\n \/\/ advance time\n if (now > (start + 170::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\nKickSynC kick1;\n\nkick1.bdmast => dac;\nkick1.trigger(1.3);\n\n1::second => now;\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"1f3f51738d85b31d900f1875fad7cfb1e3eaf345","subject":"starting to phatten out","message":"starting to phatten out\n\nlead synth just found cheesecake.\n","repos":"zeffii\/ChucKScripts","old_file":"demo_files\/chuck_rider\/score.ck","new_file":"demo_files\/chuck_rider\/score.ck","new_contents":"PolySynth polysynBass;\nPolySynth polysynArp;\nPolySynth polysynLead;\nModCarp carper;\n\ncarper.out => dac;\n\nNRev reverb_bass[2];\nreverb_bass[0].mix(0.013);\nreverb_bass[1].mix(0.013);\npolysynBass.out.gain(1.5);\npolysynBass.out.left => DelayA bassD => reverb_bass[0] => dac.left;\npolysynBass.out.right => reverb_bass[1] => dac.right;\n123::samp => bassD.delay => bassD.max;\n\nNRev reverb_arp[2];\nreverb_arp[0].mix(0.07);\nreverb_arp[1].mix(0.07);\npolysynArp.out.gain(.31);\npolysynArp.out.left => reverb_arp[0] => dac.left;\npolysynArp.out.right => DelayA arpD => reverb_arp[1] => dac.right;\n223::samp => arpD.delay => arpD.max;\n\nNRev reverb_lead[2];\nreverb_lead[0].mix(0.21);\nreverb_lead[1].mix(0.21);\npolysynLead.out.gain(.41);\nreverb_lead[0].gain(0.11);\nreverb_lead[1].gain(0.11);\npolysynLead.out => Mix2 leadgain => dac;\nleadgain.gain(0.6);\nChorus pads[2];\npolysynLead.out.left => pads[0] => reverb_lead[0] => dac.left;\npolysynLead.out.right => pads[1] => DelayA leadD => reverb_lead[1] => dac.right;\n\n\n143::samp => leadD.delay => leadD.max;\n\nfor(0 => int i; i int pseq[];\n\n[0, 52, 54, 55] @=> int arp_1_notes[];\n[0, 50, 52, 53] @=> int arp_2_notes[];\n\n[2,0,3,2,2,3,2,2,3,2,2,2,1,2,2,3,2,0,3,2,2,3,2,2,3,2,2,2,1,2,2] @=> int arp_1_triggers[];\n\n[42, 40, 43] @=> int bass_notes[];\n\n\/\/ this is mighty ugly, but it allows each note to have a unique decay length.\n[[54, 500], [0, 0], [55, 300], [54, 300], [61, 2300], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[66, 600], [0, 0], [64, 500], [66, 200], [61, 3100], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[54, 350], [0, 0], [55, 300], [54, 360], [61, 370], [0, 0], [66, 300], [0, 0], [64, 5300]\n] @=> int lead_notes_1[][];\n\n\n[[54, 500], [0, 0], [55, 300], [54, 300], [61, 2300], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[66, 600], [0, 0], [64, 500], [66, 200], [61, 3100], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[54, 350], [0, 0], [55, 300], [54, 360], [61, 370], [0, 0], [66, 300], [0, 0], [67, 5300]\n] @=> int lead_notes_2[][];\n\n\n\/\/ INTRO\nrepeat(1){\n\n polysynArp.set_envelopes(2, 217, 2, 1410);\n\n spork ~ play_lead(lead_notes_1);\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[0], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_arp(arp_2_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[1], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_lead(lead_notes_2);\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[0], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[2], pseq, 0, 32);\n advance_time(32);\n\n}\n\nfun int to_int(float input){\n input $ int => int output;\n return output;\n}\n\n\n\/\/ lead\nfun void play_lead(int sequence[][]){\n\n int tnote;\n for(0 => int i; i int tval;\n if (tval > 0) {\n tval + 12 => tnote;\n sequence[i][1] => int decay;\n polysynLead.set_envelopes(42, decay, 22, to_int(decay*1.3));\n polysynLead.play_synth([tnote, tnote], 7500.0, 2.9, 2.1);\n }\n\n advance_time();\n }\n advance_time(25);\n}\n\nfun void play_bassline(int note, int triggers[], int start, int end){\n \/\/ extra insurance\n if (end > triggers.cap()) triggers.cap() => end;\n \n for(start => int i; i int i; i int trigval;\n if (trigval > 0) {\n notes[trigval] + 12 => int note_val;\n (notes[trigval] * 90) => float filter_from_freq;\n polysynArp.play_synth([note_val,note_val], filter_from_freq+1100.0, 5.2, 2.4);\n carper.play(note_val, 0.5, 2, 140);\n }\n advance_time();\n }\n}\n\n\/\/ overloading, careful.\nfun void advance_time(int num_units){\n (0.13::second * num_units) => now;\n}\nfun void advance_time(){\n 0.13::second => now;\n}\n\n","old_contents":"PolySynth polysynBass;\nPolySynth polysynArp;\nPolySynth polysynLead;\nModCarp carper;\n\ncarper.out => dac;\n\nNRev reverb_bass[2];\nreverb_bass[0].mix(0.013);\nreverb_bass[1].mix(0.013);\npolysynBass.out.gain(1.5);\npolysynBass.out.left => DelayA bassD => reverb_bass[0] => dac.left;\npolysynBass.out.right => reverb_bass[1] => dac.right;\n123::samp => bassD.delay => bassD.max;\n\nNRev reverb_arp[2];\nreverb_arp[0].mix(0.07);\nreverb_arp[1].mix(0.07);\npolysynArp.out.gain(.31);\npolysynArp.out.left => reverb_arp[0] => dac.left;\npolysynArp.out.right => DelayA arpD => reverb_arp[1] => dac.right;\n223::samp => arpD.delay => arpD.max;\n\nNRev reverb_lead[2];\nreverb_lead[0].mix(0.59);\nreverb_lead[1].mix(0.59);\npolysynLead.out.gain(.41);\nreverb_lead[0].gain(0.09);\nreverb_lead[1].gain(0.09);\npolysynLead.out => Mix2 leadgain => dac;\nleadgain.gain(1.1);\nChorus pads[2];\npolysynLead.out.left => pads[0] => reverb_lead[0] => dac.left;\npolysynLead.out.right => pads[1] => DelayA leadD => reverb_lead[1] => dac.right;\n143::samp => leadD.delay => leadD.max;\n\nfor(0 => int i; i int pseq[];\n\n[0, 52, 54, 55] @=> int arp_1_notes[];\n[0, 50, 52, 53] @=> int arp_2_notes[];\n\n[2,0,3,2,2,3,2,2,3,2,2,2,1,2,2,3,2,0,3,2,2,3,2,2,3,2,2,2,1,2,2] @=> int arp_1_triggers[];\n\n[42, 40, 43] @=> int bass_notes[];\n\n\/\/ this is mighty ugly, but it allows each note to have a unique decay length.\n[[54, 500], [0, 0], [55, 300], [54, 300], [61, 2300], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[66, 600], [0, 0], [64, 500], [66, 200], [61, 3100], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[54, 350], [0, 0], [55, 300], [54, 360], [61, 370], [0, 0], [66, 300], [0, 0], [64, 5300]\n] @=> int lead_notes_1[][];\n\n\n[[54, 500], [0, 0], [55, 300], [54, 300], [61, 2300], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[66, 600], [0, 0], [64, 500], [66, 200], [61, 3100], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[54, 350], [0, 0], [55, 300], [54, 360], [61, 370], [0, 0], [66, 300], [0, 0], [67, 5300]\n] @=> int lead_notes_2[][];\n\n\n\/\/ INTRO\nrepeat(1){\n\n polysynArp.set_envelopes(2, 217, 2, 1410);\n\n spork ~ play_lead(lead_notes_1);\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[0], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_arp(arp_2_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[1], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_lead(lead_notes_2);\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[0], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[2], pseq, 0, 32);\n advance_time(32);\n\n}\n\nfun int to_int(float input){\n input $ int => int output;\n return output;\n}\n\n\n\/\/ lead\nfun void play_lead(int sequence[][]){\n\n int tnote;\n for(0 => int i; i int tval;\n if (tval > 0) {\n tval + 12 => tnote;\n sequence[i][1] => int decay;\n polysynLead.set_envelopes(42, decay, 22, to_int(decay*1.3));\n polysynLead.play_synth([tnote, tnote], 7500.0, 2.9, 2.1);\n }\n\n advance_time();\n }\n advance_time(25);\n}\n\nfun void play_bassline(int note, int triggers[], int start, int end){\n \/\/ extra insurance\n if (end > triggers.cap()) triggers.cap() => end;\n \n for(start => int i; i int i; i int trigval;\n if (trigval > 0) {\n notes[trigval] + 12 => int note_val;\n (notes[trigval] * 90) => float filter_from_freq;\n polysynArp.play_synth([note_val,note_val], filter_from_freq+1100.0, 5.2, 2.4);\n carper.play(note_val, 0.5, 2, 140);\n }\n advance_time();\n }\n}\n\n\/\/ overloading, careful.\nfun void advance_time(int num_units){\n (0.13::second * num_units) => now;\n}\nfun void advance_time(){\n 0.13::second => now;\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"93887df23839fdf2782f182c282b9b4699176784","subject":"more complicated test case for if","message":"more complicated test case for if\n","repos":"alltom\/luck","old_file":"src\/test\/if.ck","new_file":"src\/test\/if.ck","new_contents":"\nif(1 > 0) {\n if(false)\n <<< \"wrong\" >>>;\n else\n <<< \"right\" >>>;\n} else\n <<< \"wrong\" >>>;\n","old_contents":"\nif(1 > 0)\n <<< \"right\" >>>;\nelse\n <<< \"wrong\" >>>;\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"ChucK"} {"commit":"d17d8b27d983bbc71a2719a2065519b67eabcfc8","subject":"recording put into the file","message":"recording put into the file\n","repos":"DataOnAcid\/AudioRenderer,DataOnAcid\/AudioRenderer","old_file":"dataacid.ck","new_file":"dataacid.ck","new_contents":"\/*\nData on Acid hack\n\nIain Emsley\n\nSSI hack March 2015\n\n*\/\n\n\/\/SawOsc s => dac;\nFlute flute => PoleZero f => JCRev r => dac;\n.95 => r.gain;\n.05 => r.mix;\n.99 => f.blockZero;\n\n.2 => float timeSt;\n\/\/recording\ndac => Gain g => WvOut w => blackhole;\n\n\/\/ print out all arguments\nme.arg(0) => string inname;\nme.arg(1) => string outname;\n\nint drama[5000];\n\/\/create the array and push into a variable\nreadInts(inname) @=> drama;\n\noutname => w.wavFilename;\n\n\/\/ any gain you want for the output\n.5 => g.gain;\n\n\/\/start recording\n1 => w.record;\n\nfor (0 => int i; i w.record;\n\n\/\/ temporary workaround to automatically close file on remove-shred\nnull @=> w;\n\n\/\/ play the note\nfun void play(Flute flute, int note, float velocity) {\n \/\/ start the note\n Std.mtof( note ) => flute.freq;\n velocity => flute.noteOn;\n .6 => flute.gain;\n 100::ms => now;\n velocity => flute.noteOff;\n \/\/10::ms => now;\n}\n\n\/\/ read the ints into an array\n\/\/ http:\/\/wiki.cs.princeton.edu\/index.php\/ChucK\/Dev\/IO\/FileIO\nfun int[] readInts(string path) {\n \n \/\/ open the file\n FileIO file;\n if (!file.open(path, FileIO.READ)) {\n <<< \"file read failed\" >>>;\n <<< path >>>;\n int ret[0]; \/\/ error opening the specified file\n return ret;\n }\n \n \/\/ read the size of the array\n \/\/4096 => int size;\n file => int size;\n \/\/ now read in the contents\n int ret[size];\n for (0 => int i; i < size; i++) \n file => ret[i];\n\n file.close(); \n return ret; \n}\n","old_contents":"\/*\nData on Acid hack\n\nIain Emsley\n\nSSI hack March 2015\n\n*\/\n\n\/\/SawOsc s => dac;\nFlute flute => PoleZero f => JCRev r => dac;\n.95 => r.gain;\n.05 => r.mix;\n.99 => f.blockZero;\n\n.2 => float timeSt;\n\/\/ print out all arguments\n\n\/\/ print out all arguments\nme.arg(0) => string fname;\n\nint drama[5000];\nreadInts(fname) @=> drama;\n\nfor (0 => int i; i flute.freq;\n velocity => flute.noteOn;\n .6 => flute.gain;\n 100::ms => now;\n velocity => flute.noteOff;\n \/\/10::ms => now;\n}\n\n\/\/ read the ints into an array\n\/\/ http:\/\/wiki.cs.princeton.edu\/index.php\/ChucK\/Dev\/IO\/FileIO\nfun int[] readInts(string path) {\n \n \/\/ open the file\n FileIO file;\n if (!file.open(path, FileIO.READ)) {\n <<< \"file read failed\" >>>;\n <<< path >>>;\n int ret[0]; \/\/ error opening the specified file\n return ret;\n }\n \n \/\/ read the size of the array\n \/\/4096 => int size;\n file => int size;\n \/\/ now read in the contents\n int ret[size];\n for (0 => int i; i < size; i++) \n file => ret[i];\n\n file.close(); \n return ret; \n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"ChucK"} {"commit":"7a45f2c6fe1860fd37ac2fc06a701c8ef8207ed8","subject":"Update WaveformMixerMono.ck","message":"Update WaveformMixerMono.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/WaveformMixerMono.ck","new_file":"patches\/WaveformMixerMono.ck","new_contents":"public class WaveformMixerMono{\n\n SinOsc vsin => Gain final;\n SawOsc vsaw => final;\n TriOsc vtri => final;\n PulseOsc vpls => final; \n Noise vnse => final;\n\n 440 => float frequency;\n\n fun void pwidth(float pw){\n pw => this.vpls.width;\n }\n\n fun void freq(float frequency){\n frequency => this.frequency;\n vsin.freq(frequency);\n vsaw.freq(frequency);\n vtri.freq(frequency);\n vpls.freq(frequency);\n }\n\n fun void mixer(float components[], float mgain){\n mixer(components);\n mgain => this.final.gain;\n }\n\n fun void mixer2(float continual){\n \/\/ continual range is 0.0 to 8.0\n \/\/ goes from (sin, saw, tri, pulse to noise)\n\n float mix_comp[];\n if (continual >= 7.9996) [0.0, 0.0, 0.0, 0.0, 1.0] @=> mix_comp;\n else if (continual <= 0.0001) [1.0, 0.0, 0.0, 0.0, 0.0] @=> mix_comp;\n else {\n continual => float j;\n Math.floor(j\/2.0) $ int => int k;\n k*2 => int k2;\n ((j - k2) \/ 2.0) => float n;\n mix_arrays(k, n) @=> mix_comp;\n }\n mixer(mix_comp);\n }\n\n fun void mixer(float components[]){\n \/\/ set defautls, just in case -- make it a SinOsc\n if (!(components.cap() == 5)) {\n [1.0, 0.0, 0.0, 0.0, 0.0] @=> components;\n }\n\n float summer;\n for(0 => int i; i summer;\n }\n\n if (summer <= 0.0) { \n <<< \"no sound!\" >>>;\n 0.0 => this.vsin.gain;\n 0.0 => this.vsaw.gain;\n 0.0 => this.vtri.gain;\n 0.0 => this.vpls.gain;\n 0.0 => this.vnse.gain;\n }\n else{\n components[0] \/ summer => this.vsin.gain;\n components[1] \/ summer => this.vsaw.gain;\n components[2] \/ summer => this.vtri.gain;\n components[3] \/ summer => this.vpls.gain;\n components[4] \/ summer => this.vnse.gain;\n }\n }\n\n fun float fixmin(float fin){\n if (fin < 0.0001) return 0.0;\n else return fin;\n }\n\n fun float[] mix_arrays(int idx, float amount){\n [0.0, 0.0, 0.0, 0.0, 0.0] @=> float final_mix[];\n (1-amount) => fixmin => final_mix[idx];\n (amount) => fixmin => final_mix[idx+1];\n return final_mix;\n }\n\n}\n\n\nWaveformMixerMono bloop;\nbloop.final => dac;\n\nbloop.final.gain(0.65);\nbloop.freq(70.0);\n\nfor(0.0 => float i; i<=8.0; 0.01+=> i){\n bloop.mixer2(i);\n 25::ms => now;\n\n}\n\n","old_contents":"public class WaveformMixerMono{\n\n SinOsc vsin => Gain final;\n SawOsc vsaw => final;\n TriOsc vtri => final;\n PulseOsc vpls => final; \n Noise vnse => final;\n\n 440 => float frequency;\n\n fun void pwidth(float pw){\n pw => this.vpls.width;\n }\n\n fun void freq(float frequency){\n frequency => this.frequency;\n vsin.freq(frequency);\n vsaw.freq(frequency);\n vtri.freq(frequency);\n vpls.freq(frequency);\n }\n\n fun void mixer(float components[], float mgain){\n mixer(components);\n mgain => this.final.gain;\n }\n\n fun void mixer2(float continual){\n\n float mix_comp[];\n if (continual >= 7.9996) [0.0, 0.0, 0.0, 0.0, 1.0] @=> mix_comp;\n else if (continual <= 0.0001) [1.0, 0.0, 0.0, 0.0, 0.0] @=> mix_comp;\n else {\n continual => float j;\n Math.floor(j\/2.0) $ int => int k;\n k*2 => int k2;\n ((j - k2) \/ 2.0) => float n;\n <<< k, n >>>;\n mix_arrays(k, n) @=> mix_comp;\n }\n mixer(mix_comp);\n }\n\n fun void mixer(float components[]){\n \/\/ set defautls, just in case -- make it a SinOsc\n if (!(components.cap() == 5)) {\n [1.0, 0.0, 0.0, 0.0, 0.0] @=> components;\n }\n\n float summer;\n for(0 => int i; i summer;\n }\n\n if (summer <= 0.0) { \n <<< \"no sound!\" >>>;\n 0.0 => this.vsin.gain;\n 0.0 => this.vsaw.gain;\n 0.0 => this.vtri.gain;\n 0.0 => this.vpls.gain;\n 0.0 => this.vnse.gain;\n }\n else{\n components[0] \/ summer => this.vsin.gain;\n components[1] \/ summer => this.vsaw.gain;\n components[2] \/ summer => this.vtri.gain;\n components[3] \/ summer => this.vpls.gain;\n components[4] \/ summer => this.vnse.gain;\n }\n }\n\n fun float fixmin(float fin){\n if (fin < 0.0001) return 0.0;\n else return fin;\n }\n\n fun float[] mix_arrays(int idx, float amount){\n <<< idx, idx+1 >>>;\n [0.0, 0.0, 0.0, 0.0, 0.0] @=> float final_mix[];\n (1-amount) => fixmin => final_mix[idx];\n (amount) => fixmin => final_mix[idx+1];\n return final_mix;\n }\n\n}\n\n\/\/ Math.round\n\nWaveformMixerMono bloop;\n\/\/bloop.final => dac;\n\n\/\/ bloop.final.gain(0.1);\n\/\/ bloop.mixer([0.0, 0.0, 0.0, 0.0, 1.0]);\n\/\/ bloop.freq(500.0);\n\n\/\/ 2::second => now;\n\/\/ bloop.mixer([0.0, 0.0, 0.0, 0.0, 1.0], 0.0);\n\/\/ 0.4::second => now;\n\n\/\/ bloop.mixer([0.0, 0.0, 0.0, 0.0, 1.0], 0.2);\n\/\/ bloop.freq(500.0);\n\n\/\/ 2::second => now;\n\nfor(0.0 => float i; i<=8.0; 0.01+=> i){\n bloop.mixer2(i);\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"0b69e694b5c4abae6975f8de3a9c71efb98af10e","subject":"Update WaveformMixerMono.ck","message":"Update WaveformMixerMono.ck\n\nwoah. crazy monophonic synth osc strip.","repos":"zeffii\/ChucKScripts","old_file":"patches\/WaveformMixerMono.ck","new_file":"patches\/WaveformMixerMono.ck","new_contents":"public class WaveformMixerMono{\n\n\/*\ndef mix_arrays(idx, amount):\n finals = [0.0, 0.0, 0.0, 0.0, 0.0]\n finals[idx] = round((1-amount), 4)\n finals[idx+1] = round((amount), 4)\n print(finals)\n\njump = 10\/5\nfor i in range(0, 100):\n j = (i\/10)\n k = math.floor(j\/2)\n k2 = k*2\n n = (j - k2) \/ 2.0\n mix_arrays(k, n)\n*\/\n\n SinOsc vsin => Gain final;\n SawOsc vsaw => final;\n TriOsc vtri => final;\n PulseOsc vpls => final; \n Noise vnse => final;\n\n 440 => float frequency;\n\n fun void pwidth(float pw){\n pw => this.vpls.width;\n }\n\n fun void freq(float frequency){\n frequency => this.frequency;\n vsin.freq(frequency);\n vsaw.freq(frequency);\n vtri.freq(frequency);\n vpls.freq(frequency);\n }\n\n fun void mixer(float components[], float mgain){\n mixer(components);\n mgain => this.final.gain;\n }\n\n fun void mixer2(float continual){\n\n float mix_comp[];\n if (continual >= 7.9996) [0.0, 0.0, 0.0, 0.0, 1.0] @=> mix_comp;\n else if (continual <= 0.0001) [1.0, 0.0, 0.0, 0.0, 0.0] @=> mix_comp;\n else {\n continual => float j;\n Math.floor(j\/2.0) $ int => int k;\n k*2 => int k2;\n ((j - k2) \/ 2.0) => float n;\n <<< k, n >>>;\n mix_arrays(k, n) @=> mix_comp;\n }\n mixer(mix_comp);\n }\n\n fun void mixer(float components[]){\n \/\/ set defautls, just in case -- make it a SinOsc\n if (!(components.cap() == 5)) {\n [1.0, 0.0, 0.0, 0.0, 0.0] @=> components;\n }\n\n float summer;\n for(0 => int i; i summer;\n }\n\n if (summer <= 0.0) { \n <<< \"no sound!\" >>>;\n 0.0 => this.vsin.gain;\n 0.0 => this.vsaw.gain;\n 0.0 => this.vtri.gain;\n 0.0 => this.vpls.gain;\n 0.0 => this.vnse.gain;\n }\n else{\n components[0] \/ summer => this.vsin.gain;\n components[1] \/ summer => this.vsaw.gain;\n components[2] \/ summer => this.vtri.gain;\n components[3] \/ summer => this.vpls.gain;\n components[4] \/ summer => this.vnse.gain;\n }\n }\n\n fun float fixmin(float fin){\n if (fin < 0.0001) return 0.0;\n else return fin;\n }\n\n fun float[] mix_arrays(int idx, float amount){\n <<< idx, idx+1 >>>;\n [0.0, 0.0, 0.0, 0.0, 0.0] @=> float final_mix[];\n (1-amount) => fixmin => final_mix[idx];\n (amount) => fixmin => final_mix[idx+1];\n return final_mix;\n }\n\n}\n\n\/\/ Math.round\n\nWaveformMixerMono bloop;\n\/\/bloop.final => dac;\n\n\/\/ bloop.final.gain(0.1);\n\/\/ bloop.mixer([0.0, 0.0, 0.0, 0.0, 1.0]);\n\/\/ bloop.freq(500.0);\n\n\/\/ 2::second => now;\n\/\/ bloop.mixer([0.0, 0.0, 0.0, 0.0, 1.0], 0.0);\n\/\/ 0.4::second => now;\n\n\/\/ bloop.mixer([0.0, 0.0, 0.0, 0.0, 1.0], 0.2);\n\/\/ bloop.freq(500.0);\n\n\/\/ 2::second => now;\n\nfor(0.0 => float i; i<=8.0; 0.01+=> i){\n bloop.mixer2(i);\n}\n\n","old_contents":"public class WaveformMixerMono{\n \n SinOsc vsin => Gain final;\n SawOsc vsaw => final;\n TriOsc vtri => final;\n PulseOsc vpls => final; \n Noise vnse => final;\n \n 440 => float frequency;\n \n fun void freq(float frequency){\n frequency => this.frequency;\n vsin.freq(frequency);\n vsaw.freq(frequency);\n vtri.freq(frequency);\n vpls.freq(frequency);\n }\n \n fun void mixer(float components[]){\n \/\/ set defautls, just in case -- make it a SinOsc\n if (!(components.cap() == 5)) {\n [1.0, 0.0, 0.0, 0.0, 0.0] @=> components;\n }\n \n float summer;\n for(0 => int i; i summer;\n }\n \n if (summer <= 0.0) { \n <<< \"no sound!\" >>>;\n 0.0 => this.vsin.gain;\n 0.0 => this.vsaw.gain;\n 0.0 => this.vtri.gain;\n 0.0 => this.vpls.gain;\n 0.0 => this.vnse.gain;\n }\n else{\n components[0] \/ summer => this.vsin.gain;\n components[1] \/ summer => this.vsaw.gain;\n components[2] \/ summer => this.vtri.gain;\n components[3] \/ summer => this.vpls.gain;\n components[4] \/ summer => this.vnse.gain;\n }\n }\n}\n \nWaveformMixerMono bloop;\nbloop.final => dac;\nbloop.final.gain(0.4);\nbloop.mixer([0.0, 0.0, 1.0, 0.0, 0.0]);\nbloop.freq(500.0);\n \n2::second => now;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"b61a52e12d26611eb140f09b9f5a084f3c7dda98","subject":"colors are a bit more obvious now","message":"colors are a bit more obvious now\n","repos":"jordanorelli\/wii-chuck-synth","old_file":"resin_run.ck","new_file":"resin_run.ck","new_contents":"OscRecv wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float wiiAccel;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.green => int keyOnColor;\nLaunchpadColor.red => int keySustainColor;\nLaunchpadColor.orange => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 82.4068867, 12.0) @=> oscBank;\n\n if(prompt) {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n Launchpad.Launchpad(lpChannel) @=> lp;\n } else {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone) { return; }\n else if(toneChoice == 0) { oscBank.setPatch(\"SinOsc\"); }\n else if(toneChoice == 1) { oscBank.setPatch(\"SqrOsc\"); }\n else if(toneChoice == 2) { oscBank.setPatch(\"SawOsc\"); }\n else if(toneChoice == 3) { oscBank.setPatch(\"TriOsc\"); }\n else { return; } \n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void setSostenuto(int enabled) {\n enabled => sostenuto;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] && enabled => sostenutoStatus[x][y];\n if(!enabled && !lp.keyDown[x][y] && !sustainStatus[x][y]) {\n lp.setGridLight(x, y, 0);\n }\n }\n }\n}\n\nfun void setSustain(int enabled) {\n enabled => sustain;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] => int down;\n down && enabled => sustainStatus[x][y];\n if(!down && !sostenutoStatus[x][y]) {\n lp.setGridLight(x, y, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (wiiAccel - 32) \/ 95.0) => targetGain;\n wiiAccel => targetGain;\n\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\nfun void sustainListener() {\n wm.event(\"\/wii\/1\/button\/B,i\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSustain(e.getInt() != 0);\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,i\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSostenuto(e.getInt() != 0);\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n Math.max(0.0, e.getFloat() - 0.22) => wiiAccel;\n chout <= wiiAccel <= IO.newline();\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n \/\/ 8000 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true) { 1::second => now; }\n}\n\nsetup();\nwhile(true) { 100::ms => now; }\n","old_contents":"OscRecv wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float rawGain;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 82.4068867, 12.0) @=> oscBank;\n\n if(prompt) {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n Launchpad.Launchpad(lpChannel) @=> lp;\n } else {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone) { return; }\n else if(toneChoice == 0) { oscBank.setPatch(\"SinOsc\"); }\n else if(toneChoice == 1) { oscBank.setPatch(\"SqrOsc\"); }\n else if(toneChoice == 2) { oscBank.setPatch(\"SawOsc\"); }\n else if(toneChoice == 3) { oscBank.setPatch(\"TriOsc\"); }\n else { return; } \n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void setSostenuto(int enabled) {\n enabled => sostenuto;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] && enabled => sostenutoStatus[x][y];\n if(!enabled && !lp.keyDown[x][y] && !sustainStatus[x][y]) {\n lp.setGridLight(x, y, 0);\n }\n }\n }\n}\n\nfun void setSustain(int enabled) {\n enabled => sustain;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] => int down;\n down && enabled => sustainStatus[x][y];\n if(!down && !sostenutoStatus[x][y]) {\n lp.setGridLight(x, y, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n rawGain => targetGain;\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\nfun void sustainListener() {\n wm.event(\"\/wii\/1\/button\/B,i\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSustain(e.getInt() != 0);\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,i\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSostenuto(e.getInt() != 0);\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n Math.max(0.0, e.getFloat() - 0.22) => rawGain;\n chout <= rawGain <= IO.newline();\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n \/\/ 8000 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true)\n {\n 1::second => now;\n }\n}\n\nsetup();\nwhile(true) { 100::ms => now; }\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"8d9fa9e557405d8c51e6ce159384d2ddcdceff5a","subject":"130902.0","message":"130902.0\n","repos":"reidiiius\/nautiloidea","old_file":"doc\/gamut\/spectra.ck","new_file":"doc\/gamut\/spectra.ck","new_contents":"\/\/ spectra.ck \r\nTriOsc s => dac;\r\n0.5 => s.gain;\r\n\r\n21=>int an0;\r\n21=>int by0;\r\n22=>int ak0;\r\n22=>int bj0;\r\n23=>int bn0;\r\n23=>int cj1;\r\n24=>int bk0;\r\n24=>int cn1;\r\n25=>int ck1;\r\n25=>int dj1;\r\n26=>int cx1;\r\n26=>int dn1;\r\n26=>int ey1;\r\n27=>int dk1;\r\n27=>int ej1;\r\n28=>int en1;\r\n28=>int fj1;\r\n29=>int ek1;\r\n29=>int fn1;\r\n30=>int fk1;\r\n30=>int gj1;\r\n31=>int fx1;\r\n31=>int gn1;\r\n32=>int gk1;\r\n32=>int aj1;\r\n33=>int an1;\r\n33=>int by1;\r\n34=>int ak1;\r\n34=>int bj1;\r\n35=>int bn1;\r\n35=>int cj2;\r\n36=>int bk1;\r\n36=>int cn2;\r\n37=>int ck2;49=>int ck3;61=>int ck4;73=>int ck5;85=>int ck6; 97=>int ck7;\r\n37=>int dj2;49=>int dj3;61=>int dj4;73=>int dj5;85=>int dj6; 97=>int dj7;\r\n38=>int cx2;50=>int cx3;62=>int cx4;74=>int cx5;86=>int cx6; 98=>int cx7;\r\n38=>int dn2;50=>int dn3;62=>int dn4;74=>int dn5;86=>int dn6; 98=>int dn7;\r\n38=>int ey2;50=>int ey3;62=>int ey4;74=>int ey5;86=>int ey6; 98=>int ey7;\r\n39=>int dk2;51=>int dk3;63=>int dk4;75=>int dk5;87=>int dk6; 99=>int dk7;\r\n39=>int ej2;51=>int ej3;63=>int ej4;75=>int ej5;87=>int ej6; 99=>int ej7;\r\n40=>int en2;52=>int en3;64=>int en4;76=>int en5;88=>int en6;100=>int en7;\r\n40=>int fj2;52=>int fj3;64=>int fj4;76=>int fj5;88=>int fj6;100=>int fj7;\r\n41=>int ek2;53=>int ek3;65=>int ek4;77=>int ek5;89=>int ek6;101=>int ek7;\r\n41=>int fn2;53=>int fn3;65=>int fn4;77=>int fn5;89=>int fn6;101=>int fn7;\r\n42=>int fk2;54=>int fk3;66=>int fk4;78=>int fk5;90=>int fk6;102=>int fk7;\r\n42=>int gj2;54=>int gj3;66=>int gj4;78=>int gj5;90=>int gj6;102=>int gj7;\r\n43=>int fx2;55=>int fx3;67=>int fx4;79=>int fx5;91=>int fx6;103=>int fx7;\r\n43=>int gn2;55=>int gn3;67=>int gn4;79=>int gn5;91=>int gn6;103=>int gn7;\r\n44=>int gk2;56=>int gk3;68=>int gk4;80=>int gk5;92=>int gk6;104=>int gk7;\r\n44=>int aj2;56=>int aj3;68=>int aj4;80=>int aj5;92=>int aj6;104=>int aj7;\r\n45=>int an2;57=>int an3;69=>int an4;81=>int an5;93=>int an6;105=>int an7;\r\n45=>int by2;57=>int by3;69=>int by4;81=>int by5;93=>int by6;105=>int by7;\r\n46=>int ak2;58=>int ak3;70=>int ak4;82=>int ak5;94=>int ak6;106=>int ak7;\r\n46=>int bj2;58=>int bj3;70=>int bj4;82=>int bj5;94=>int bj6;106=>int bj7;\r\n47=>int bn2;59=>int bn3;71=>int bn4;83=>int bn5;95=>int bn6;107=>int bn7;\r\n47=>int cj3;59=>int cj4;71=>int cj5;83=>int cj6;95=>int cj7;107=>int cj8;\r\n48=>int bk2;60=>int bk3;72=>int bk4;84=>int bk5;96=>int bk6;108=>int bk7;\r\n48=>int cn3;60=>int cn4;72=>int cn5;84=>int cn6;96=>int cn7;108=>int cn8;\r\n\r\n144 => int tempo;\r\n 0 => int transport;\r\n\r\n[\r\n[an0,8],[ak0,8],[bn0,8],[cn1,8],[ck1,8],[dn1,8],[dk1,8],[en1,8],[fn1,8],[fk1,8],[gn1,8],[gk1,8],\r\n[an1,8],[ak1,8],[bn1,8],[cn2,8],[ck2,8],[dn2,8],[dk2,8],[en2,8],[fn2,8],[fk2,8],[gn2,8],[gk2,8],\r\n[an2,8],[ak2,8],[bn2,8],[cn3,8],[ck3,8],[dn3,8],[dk3,8],[en3,8],[fn3,8],[fk3,8],[gn3,8],[gk3,8],\r\n[an3,8],[ak3,8],[bn3,8],[cn4,8],[ck4,8],[dn4,8],[dk4,8],[en4,8],[fn4,8],[fk4,8],[gn4,8],[gk4,8],\r\n[an4,8],[ak4,8],[bn4,8],[cn5,8],[ck5,8],[dn5,8],[dk5,8],[en5,8],[fn5,8],[fk5,8],[gn5,8],[gk5,8],\r\n[an5,8],[ak5,8],[bn5,8],[cn6,8],[ck6,8],[dn6,8],[dk6,8],[en6,8],[fn6,8],[fk6,8],[gn6,8],[gk6,8],\r\n[an6,8],[ak6,8],[bn6,8],[cn7,8],[ck7,8],[dn7,8],[dk7,8],[en7,8],[fn7,8],[fk7,8],[gn7,8],[gk7,8],\r\n[an7,8],[aj7,8],[gn7,8],[gj7,8],[fn7,8],[en7,8],[ej7,8],[dn7,8],[dj7,8],[cn7,8],[bn6,8],[bj6,8],\r\n[an6,8],[aj6,8],[gn6,8],[gj6,8],[fn6,8],[en6,8],[ej6,8],[dn6,8],[dj6,8],[cn6,8],[bn5,8],[bj5,8],\r\n[an5,8],[aj5,8],[gn5,8],[gj5,8],[fn5,8],[en5,8],[ej5,8],[dn5,8],[dj5,8],[cn5,8],[bn4,8],[bj4,8],\r\n[an4,8],[aj4,8],[gn4,8],[gj4,8],[fn4,8],[en4,8],[ej4,8],[dn4,8],[dj4,8],[cn4,8],[bn3,8],[bj3,8],\r\n[an3,8],[aj3,8],[gn3,8],[gj3,8],[fn3,8],[en3,8],[ej3,8],[dn3,8],[dj3,8],[cn3,8],[bn2,8],[bj2,8],\r\n[an2,8],[aj2,8],[gn2,8],[gj2,8],[fn2,8],[en2,8],[ej2,8],[dn2,8],[dj2,8],[cn2,8],[bn1,8],[bj1,8],\r\n[an1,8],[aj1,8],[gn1,8],[gj1,8],[fn1,8],[en1,8],[ej1,8],[dn1,8],[dj1,8],[cn1,8],[bn0,8],[bj0,8]\r\n] @=> int spectra[][];\r\n\r\nwhile ( true ) \r\nfor( 0 => int i; i < spectra.cap(); i++) {\r\n Std.mtof( spectra[i][0] + transport ) => s.freq;\r\n 240000::ms \/ ( spectra[i][1] * tempo ) => now; } \r\n","old_contents":"\/\/ spectra.ck \r\nTriOsc s => dac;\r\n0.5 => s.gain; \r\n\r\n 21 => int an0; 33 => int an1; 45 => int an2; 57 => int an3; 69 => int an4; 81 => int an5; 93 => int an6;105 => int an7;117 => int an8; \r\n 21 => int by0; 33 => int by1; 45 => int by2; 57 => int by3; 69 => int by4; 81 => int by5; 93 => int by6;105 => int by7; \r\n 22 => int ak0; 34 => int ak1; 46 => int ak2; 58 => int ak3; 70 => int ak4; 82 => int ak5; 94 => int ak6;106 => int ak7; \r\n 22 => int bj0; 34 => int bj1; 46 => int bj2; 58 => int bj3; 70 => int bj4; 82 => int bj5; 94 => int bj6;106 => int bj7; \r\n 23 => int bn0; 35 => int bn1; 47 => int bn2; 59 => int bn3; 71 => int bn4; 83 => int bn5; 95 => int bn6;107 => int bn7; \r\n 23 => int cj1; 35 => int cj2; 47 => int cj3; 59 => int cj4; 71 => int cj5; 83 => int cj6; 95 => int cj7;107 => int cj8; \r\n 24 => int bk0; 36 => int bk1; 48 => int bk2; 60 => int bk3; 72 => int bk4; 84 => int bk5; 96 => int bk6;108 => int bk7; \r\n 24 => int cn1; 36 => int cn2; 48 => int cn3; 60 => int cn4; 72 => int cn5; 84 => int cn6; 96 => int cn7;108 => int cn8; \r\n 25 => int ck1; 37 => int ck2; 49 => int ck3; 61 => int ck4; 73 => int ck5; 85 => int ck6; 97 => int ck7;109 => int ck8; \r\n 25 => int dj1; 37 => int dj2; 49 => int dj3; 61 => int dj4; 73 => int dj5; 85 => int dj6; 97 => int dj7;109 => int dj8; \r\n 26 => int cx1; 38 => int cx2; 50 => int cx3; 62 => int cx4; 74 => int cx5; 86 => int cx6; 98 => int cx7;110 => int cx8; \r\n 26 => int dn1; 38 => int dn2; 50 => int dn3; 62 => int dn4; 74 => int dn5; 86 => int dn6; 98 => int dn7;110 => int dn8; \r\n 26 => int ey1; 38 => int ey2; 50 => int ey3; 62 => int ey4; 74 => int ey5; 86 => int ey6; 98 => int ey7;110 => int ey8; \r\n 27 => int dk1; 39 => int dk2; 51 => int dk3; 63 => int dk4; 75 => int dk5; 87 => int dk6; 99 => int dk7;111 => int dk8; \r\n 27 => int ej1; 39 => int ej2; 51 => int ej3; 63 => int ej4; 75 => int ej5; 87 => int ej6; 99 => int ej7;111 => int ej8; \r\n 28 => int en1; 40 => int en2; 52 => int en3; 64 => int en4; 76 => int en5; 88 => int en6;100 => int en7;112 => int en8; \r\n 28 => int fj1; 40 => int fj2; 52 => int fj3; 64 => int fj4; 76 => int fj5; 88 => int fj6;100 => int fj7;112 => int fj8; \r\n 29 => int ek1; 41 => int ek2; 53 => int ek3; 65 => int ek4; 77 => int ek5; 89 => int ek6;101 => int ek7;113 => int ek8; \r\n 29 => int fn1; 41 => int fn2; 53 => int fn3; 65 => int fn4; 77 => int fn5; 89 => int fn6;101 => int fn7;113 => int fn8; \r\n 30 => int fk1; 42 => int fk2; 54 => int fk3; 66 => int fk4; 78 => int fk5; 90 => int fk6;102 => int fk7;114 => int fk8; \r\n 30 => int gj1; 42 => int gj2; 54 => int gj3; 66 => int gj4; 78 => int gj5; 90 => int gj6;102 => int gj7;114 => int gj8; \r\n 31 => int fx1; 43 => int fx2; 55 => int fx3; 67 => int fx4; 79 => int fx5; 91 => int fx6;103 => int fx7;115 => int fx8; \r\n 31 => int gn1; 43 => int gn2; 55 => int gn3; 67 => int gn4; 79 => int gn5; 91 => int gn6;103 => int gn7;115 => int gn8; \r\n 32 => int gk1; 44 => int gk2; 56 => int gk3; 68 => int gk4; 80 => int gk5; 92 => int gk6;104 => int gk7;116 => int gk8; \r\n 32 => int aj1; 44 => int aj2; 56 => int aj3; 68 => int aj4; 80 => int aj5; 92 => int aj6;104 => int aj7;116 => int aj8; \r\n\r\n144 => int tempo;\r\n 0 => int transport;\r\n\r\n[[an0,8],[ak0,8],[bn0,8],[cn1,8],[ck1,8],[dn1,8],[dk1,8],[en1,8],[fn1,8],[fk1,8],[gn1,8],[gk1,8],\r\n [an1,8],[ak1,8],[bn1,8],[cn2,8],[ck2,8],[dn2,8],[dk2,8],[en2,8],[fn2,8],[fk2,8],[gn2,8],[gk2,8],\r\n [an2,8],[ak2,8],[bn2,8],[cn3,8],[ck3,8],[dn3,8],[dk3,8],[en3,8],[fn3,8],[fk3,8],[gn3,8],[gk3,8],\r\n [an3,8],[ak3,8],[bn3,8],[cn4,8],[ck4,8],[dn4,8],[dk4,8],[en4,8],[fn4,8],[fk4,8],[gn4,8],[gk4,8],\r\n [an4,8],[ak4,8],[bn4,8],[cn5,8],[ck5,8],[dn5,8],[dk5,8],[en5,8],[fn5,8],[fk5,8],[gn5,8],[gk5,8],\r\n [an5,8],[ak5,8],[bn5,8],[cn6,8],[ck6,8],[dn6,8],[dk6,8],[en6,8],[fn6,8],[fk6,8],[gn6,8],[gk6,8],\r\n [an6,8],[ak6,8],[bn6,8],[cn7,8],[ck7,8],[dn7,8],[dk7,8],[en7,8],[fn7,8],[fk7,8],[gn7,8],[gk7,8],\r\n [an7,8],[ak7,8],[bn7,8],[cn8,8],[ck8,8],[dn8,8],[dk8,8],[en8,8],[fn8,8],[fk8,8],[gn8,8],[gk8,8],\r\n [an8,8],[aj8,8],[gn8,8],[gj8,8],[fn8,8],[en8,8],[ej8,8],[dn8,8],[dj8,8],[cn8,8],[bn7,8],[bj7,8],\r\n [an7,8],[aj7,8],[gn7,8],[gj7,8],[fn7,8],[en7,8],[ej7,8],[dn7,8],[dj7,8],[cn7,8],[bn6,8],[bj6,8],\r\n [an6,8],[aj6,8],[gn6,8],[gj6,8],[fn6,8],[en6,8],[ej6,8],[dn6,8],[dj6,8],[cn6,8],[bn5,8],[bj5,8],\r\n [an5,8],[aj5,8],[gn5,8],[gj5,8],[fn5,8],[en5,8],[ej5,8],[dn5,8],[dj5,8],[cn5,8],[bn4,8],[bj4,8],\r\n [an4,8],[aj4,8],[gn4,8],[gj4,8],[fn4,8],[en4,8],[ej4,8],[dn4,8],[dj4,8],[cn4,8],[bn3,8],[bj3,8],\r\n [an3,8],[aj3,8],[gn3,8],[gj3,8],[fn3,8],[en3,8],[ej3,8],[dn3,8],[dj3,8],[cn3,8],[bn2,8],[bj2,8],\r\n [an2,8],[aj2,8],[gn2,8],[gj2,8],[fn2,8],[en2,8],[ej2,8],[dn2,8],[dj2,8],[cn2,8],[bn1,8],[bj1,8],\r\n [an1,8],[aj1,8],[gn1,8],[gj1,8],[fn1,8],[en1,8],[ej1,8],[dn1,8],[dj1,8],[cn1,8],[bn0,8],[bj0,8]] @=> int spectra[][];\r\n\r\nwhile ( true ) \r\nfor( 0 => int i; i < spectra.cap(); i++) {\r\n Std.mtof( spectra[i][0] + transport ) => s.freq;\r\n 240000::ms \/ ( spectra[i][1] * tempo ) => now; } \r\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"43ca53702a1a104d0129de36e5dde417245a23a7","subject":"removed evil brackets","message":"removed evil brackets\n","repos":"jordanorelli\/wii-chuck-synth","old_file":"resin_run.ck","new_file":"resin_run.ck","new_contents":"MidiIn wm;\nLaunchpad lp;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0 => int rawGain;\n UGen @ oscBank[8][8];\n Gain @ patchBank[8][8];\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n1 => int wiimoteChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\nToneCalc.grid(8, 8, 1, 5, 82.4068867, 12.0) @=> float toneMap[][];\n\nfun void setup()\n{\n\n if(prompt)\n {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n intPrompt(\"Enter Midi Channel for Wiimote input: \") => wiimoteChannel;\n\n Launchpad.Launchpad(lpChannel) @=> lp;\n connectWiimote(wiimoteChannel);\n }\n else\n {\n Launchpad.Launchpad(0) @=> lp;\n connectWiimote(1);\n }\n\n\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n chout <= \"Create oscillators\" <= IO.newline();\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n SinOsc s;\n toneMap[i][j] => s.freq;\n 0.0 => s.gain;\n chout <= \".\";\n\n Gain g;\n 1.0 => g.gain;\n\n s @=> oscBank[i][j] => g @=> patchBank[i][j] => dac;\n }\n }\n chout <= \"done.\" <= IO.newline();\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun UGen toneChoiceFactory(int toneChoice, UGen @ sourceUGen, float freq)\n{\n if(toneChoice == 0)\n {\n SinOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n }\n else if(toneChoice == 1)\n {\n TriOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n }\n else if(toneChoice == 2)\n {\n SqrOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n }\n else if(toneChoice == 3)\n {\n SawOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n }\n else\n {\n cherr <= \"Unrecognized input fed to toneChoiceFactory: \" <= toneChoice\n <= IO.newline();\n SinOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n }\n}\n\nfun void setTone(int toneChoice)\n{\n\n if(toneChoice == currentTone)\n {\n return;\n }\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n UGen u;\n toneChoiceFactory(toneChoice, oscBank[i][j], toneMap[i][j]) @=> u;\n 0 => oscBank[i][j].op;\n oscBank[i][j] =< patchBank[i][j];\n u @=> oscBank[i][j] => patchBank[i][j];\n }\n }\n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void sostenutoOn()\n{\n true => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sostenutoStatus[i][j];\n }\n }\n }\n}\n\nfun void sostenutoOff()\n{\n false => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sostenutoStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void sustainOn()\n{\n true => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sustainStatus[i][j];\n }\n }\n }\n}\n\nfun void sustainOff()\n{\n false => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sustainStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank[column][row].gain() - releaseDecay, 0.00)\n => oscBank[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank[column][row].gain() - sustainDecay, 0.00)\n => oscBank[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank[column][row].gain())\n {\n Math.min(oscBank[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 8) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\nfun void wiiParser(MidiMsg msg)\n{\n if(msg.data1 == 176) \/\/ midi CC\n {\n if(msg.data2 == 64)\n { \/\/ wiimote acceleration\n msg.data3 => rawGain;\n }\n else if (msg.data2 == 65)\n { \/\/ wiimote button b\n if(msg.data3 == 127)\n {\n sustainOn();\n }\n else\n {\n sustainOff();\n }\n }\n else if (msg.data2 == 66)\n { \/\/ wiimote button a\n if(msg.data3 == 127)\n {\n sostenutoOn();\n }\n else\n {\n sostenutoOff();\n }\n }\n }\n}\n\nfun void connectWiimote(int midiChannel)\n{\n if(!wm.open(midiChannel)) me.exit();\n\n chout <= \"Midi device: \" <= midiChannel <= \" -> \" <= wm.name()\n <= IO.newline();\n}\n\nfun void wiiListener()\n{\n MidiMsg msg;\n while(true)\n {\n wm => now;\n while(wm.recv(msg))\n {\n wiiParser(msg);\n }\n }\n}\n\nsetup();\n\nwhile(true)\n{\n 100::ms => now;\n}\n","old_contents":"MidiIn wm;\nLaunchpad lp;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.0001 => float sustainDecay;\n0.0001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0 => int rawGain;\n UGen @ oscBank[8][8];\n Gain @ patchBank[8][8];\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n1 => int wiimoteChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\nToneCalc.grid(8, 8, 1, 5, 82.4068867, 12.0) @=> float toneMap[][];\n\nfun void setup() {\n\n if(prompt) {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n intPrompt(\"Enter Midi Channel for Wiimote input: \") => wiimoteChannel;\n\n Launchpad.Launchpad(lpChannel) @=> lp;\n connectWiimote(wiimoteChannel);\n } else {\n Launchpad.Launchpad(0) @=> lp;\n connectWiimote(1);\n }\n\n\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n chout <= \"Create oscillators\" <= IO.newline();\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n SinOsc s;\n toneMap[i][j] => s.freq;\n 0.0 => s.gain;\n chout <= \".\";\n\n Gain g;\n 1.0 => g.gain;\n\n s @=> oscBank[i][j] => g @=> patchBank[i][j] => dac;\n }\n }\n chout <= \"done.\" <= IO.newline();\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun UGen toneChoiceFactory(int toneChoice, UGen @ sourceUGen, float freq) {\n if(toneChoice == 0) {\n SinOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n } else if(toneChoice == 1) {\n TriOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n } else if(toneChoice == 2) {\n SqrOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n } else if(toneChoice == 3) {\n SawOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n } else {\n cherr <= \"Unrecognized input fed to toneChoiceFactory: \" <= toneChoice\n <= IO.newline();\n SinOsc s;\n freq => s.freq;\n sourceUGen.op() => s.op;\n sourceUGen.gain() => s.gain;\n return s;\n }\n}\n\nfun void setTone(int toneChoice) {\n\n if(toneChoice == currentTone) {\n return;\n }\n\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n UGen u;\n toneChoiceFactory(toneChoice, oscBank[i][j], toneMap[i][j]) @=> u;\n 0 => oscBank[i][j].op;\n oscBank[i][j] =< patchBank[i][j];\n u @=> oscBank[i][j] => patchBank[i][j];\n }\n }\n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void sostenutoOn() {\n true => sostenuto;\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n if(lp.keyDown[i][j]) {\n true => sostenutoStatus[i][j];\n }\n }\n }\n}\n\nfun void sostenutoOff() {\n false => sostenuto;\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n false => sostenutoStatus[i][j];\n if(!lp.keyDown[i][j]) {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void sustainOn() {\n true => sustain;\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n if(lp.keyDown[i][j]) {\n true => sustainStatus[i][j];\n }\n }\n }\n}\n\nfun void sustainOff() {\n false => sustain;\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n false => sustainStatus[i][j];\n if(!lp.keyDown[i][j]) {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row) {\n Math.max(oscBank[column][row].gain() - releaseDecay, 0.00)\n => oscBank[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain) {\n if(sustain && sustainStatus[column][row]) {\n Math.max(oscBank[column][row].gain() - sustainDecay, 0.00)\n => oscBank[column][row].gain;\n } else {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain) {\n if(sostenuto && sostenutoStatus[column][row]) {\n Math.max(oscBank[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank[column][row].gain;\n } else {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain) {\n if(lp.keyDown[column][row] && targetGain > oscBank[column][row].gain()) {\n Math.min(oscBank[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank[column][row].gain;\n } else {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains() {\n float targetGain;\n while(true) {\n Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg) {\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more()) {\n tok.set(cin.getLine());\n while(tok.more()) {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener() {\n while(true) {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 8) continue;\n\n if(lp.e.column == 8) {\n if(lp.e.velocity == 127) {\n setTone(lp.e.row);\n }\n } else if(lp.e.velocity == 127) {\n if(sustain) {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank[lp.e.column][lp.e.row].op;\n } else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row]) {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n } else if(sustain && sustainStatus[lp.e.column][lp.e.row]) {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n } else {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\nfun void wiiParser(MidiMsg msg) {\n if(msg.data1 == 176) { \/\/ midi CC\n if(msg.data2 == 64) { \/\/ wiimote acceleration\n msg.data3 => rawGain;\n } else if (msg.data2 == 65) { \/\/ wiimote button b\n if(msg.data3 == 127) {\n sustainOn();\n } else {\n sustainOff();\n }\n } else if (msg.data2 == 66) { \/\/ wiimote button a\n if(msg.data3 == 127) {\n sostenutoOn();\n } else {\n sostenutoOff();\n }\n }\n }\n}\n\nfun void connectWiimote(int midiChannel)\n{\n if(!wm.open(midiChannel)) me.exit();\n\n chout <= \"Midi device: \" <= midiChannel <= \" -> \" <= wm.name()\n <= IO.newline();\n}\n\nfun void wiiListener() {\n MidiMsg msg;\n while(true) {\n wm => now;\n while(wm.recv(msg)) {\n wiiParser(msg);\n }\n }\n}\n\nsetup();\n\nwhile(true) {\n 100::ms => now;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"b64002c1087737c147a5039642195cddf7d01086","subject":"Update vibraphoney.ck","message":"Update vibraphoney.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/melodic\/vibraphoney.ck","new_file":"patches\/melodic\/vibraphoney.ck","new_contents":"Gain vibGain => dac;\n\nvibGain.gain(4.0);\n\n[46, 48, 49, 51, 53, 54, 56, 58] @=> int scale[];\n\nrepeat(3){\n for(0 => int i; i < scale.cap(); i++)\n { \n <<< i >>>;\n scale[i] => int note;\n spork ~ play_vibra(note);\n .2::second => now;\n }\n}\n\nfun void play_vibra(int note){\n\n ModalBar modalBar => ADSR vibEnv => vibGain;\n 320 => modalBar.vibratoFreq;\n 6 => modalBar.preset;\n\n \/\/ control change takes to parameters, \n \/\/ - int, range: depends on parameter\n \/\/ - float, range: 0.0...128.0\n modalBar.controlChange(2, 123.0); \/\/ - Stick Hardness\n modalBar.controlChange(4, 27.0); \/\/ - Stick Position\n modalBar.controlChange(11, 53.0); \/\/ - Vibrato Gain \n modalBar.controlChange(7, 115.0); \/\/ - Vibrato Frequency\n modalBar.controlChange(1, 0.01); \/\/ - Direct Stick Mix\n modalBar.controlChange(128, 0.2); \/\/ - Volume\n\n vibEnv.set( 42::ms, 371::ms, 0.80, 35::ms ); \/\/a, d, s, r\n vibEnv.keyOn();\n Std.mtof(note)*2 => modalBar.freq;\n 1.0 => modalBar.noteOn; \n .75 => modalBar.strike;\n 1.4::second => now;\n\n modalBar =< vibGain;\n\n}\n","old_contents":"Gain vibGain => dac;\n\nvibGain.gain(4.0);\n\n[46, 48, 49, 51, 53, 54, 56, 58] @=> int scale[];\n\nrepeat(3){\n for(0 => int i; i < scale.cap(); i++)\n { \n <<< i >>>;\n scale[i] => int note;\n spork ~ play_vibra(note);\n .2::second => now;\n }\n}\n\nfun void play_vibra(int note){\n\n ModalBar modalBar => ADSR vibEnv => vibGain;\n 320 => modalBar.vibratoFreq;\n 6 => modalBar.preset;\n\n \/\/int, float (0.0 128.0)\n modalBar.controlChange(2, 123.0); \/\/ - Stick Hardness\n modalBar.controlChange(4, 27.0); \/\/ - Stick Position\n modalBar.controlChange(11, 53.0); \/\/ - Vibrato Gain \n modalBar.controlChange(7, 115.0); \/\/ - Vibrato Frequency\n modalBar.controlChange(1, 0.01); \/\/ - Direct Stick Mix\n modalBar.controlChange(128, 0.2); \/\/ - Volume\n\n vibEnv.set( 42::ms, 371::ms, 0.80, 35::ms ); \/\/a, d, s, r\n vibEnv.keyOn();\n Std.mtof(note)*2 => modalBar.freq;\n 1.0 => modalBar.noteOn; \n .75 => modalBar.strike;\n 1.4::second => now;\n\n modalBar =< vibGain;\n\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"beb65ee3057aa7e85b90c74c8fdc1d1d325a7134","subject":"louisiana: more padding on ck script","message":"louisiana: more padding on ck script\n","repos":"rblades\/music-lab-scripts,beefoo\/music-lab-scripts,beefoo\/music-lab-scripts,beefoo\/music-lab-scripts,shawngraham\/music-lab-scripts","old_file":"07_louisiana\/louisiana.ck","new_file":"07_louisiana\/louisiana.ck","new_contents":"0 => int padding_start;\n12000 => int padding_end;\n2 => int instrument_buffers;\n0 => int start;\nme.sourceDir() => string base_dir;\n\n\/\/ normalize base directory\nif (base_dir.charAt(base_dir.length()-1) != '\/')\n{\n \"\/\" +=> base_dir;\n}\n\n\/\/ instrument object\nclass Instrument {\n string filename;\n SndBuf buf[8];\n int plays;\n}\n\n\/\/ data files\nbase_dir + \"data\/ck_instruments.csv\" => string instruments_file;\nbase_dir + \"data\/ck_sequence.csv\" => string sequence_file;\n\n\/\/ read data files\nFileIO instruments_fio;\nFileIO sequence_fio;\ninstruments_fio.open( instruments_file, FileIO.READ );\nsequence_fio.open( sequence_file, FileIO.READ );\n\n\/\/ check if files are valid\nif( !instruments_fio.good() || !sequence_fio.good() )\n{\n cherr <= \"can't open instrument and\/or sequence files for reading...\"\n <= IO.newline();\n me.exit();\n}\n\n\/\/ create instruments array\nInstrument instruments[256];\n\n\/\/ read instruments file\nwhile( instruments_fio.more() )\n{\n \/\/ read instrument index and filename\n Std.atoi(instruments_fio.readLine()) => int instrument_index;\n instruments_fio.readLine() => string filename;\n filename.find(\"\\r\") => int return_match;\n if (return_match >= 0)\n {\n filename.erase(return_match, 1);\n }\n base_dir + filename => instruments[instrument_index].filename;\n 0 => instruments[instrument_index].plays;\n \/\/ create buffers from filename\n for( 0 => int i; i < instrument_buffers; i++ )\n {\n instruments[instrument_index].filename => instruments[instrument_index].buf[i].read;\n \/\/ set position to end, so it won't play immediately upon open\n instruments[instrument_index].buf[i].samples() => instruments[instrument_index].buf[i].pos;\n instruments[instrument_index].buf[i] => dac;\n }\n\n}\n\n\n\/\/ Add padding\npadding_start::ms => now;\npadding_start => int elapsed_ms;\n\n\/\/ read sequence from file\nwhile( sequence_fio.more() ) {\n Std.atoi(sequence_fio.readLine()) => int instrument_index;\n Std.atoi(sequence_fio.readLine()) => int position;\n Std.atof(sequence_fio.readLine()) => float gain;\n Std.atof(sequence_fio.readLine()) => float rate;\n Std.atoi(sequence_fio.readLine()) => int milliseconds;\n\n elapsed_ms + milliseconds => elapsed_ms;\n if (start > elapsed_ms)\n {\n continue;\n }\n\n \/\/ wait duration\n\tif (milliseconds > 0)\n {\n milliseconds::ms => now;\n }\n\n \/\/ choose buffer index\n instruments[instrument_index].plays % instrument_buffers => int buffer_index;\n instruments[instrument_index].plays++;\n\n \/\/ play the instrument\n position => instruments[instrument_index].buf[buffer_index].pos;\n gain => instruments[instrument_index].buf[buffer_index].gain;\n rate => instruments[instrument_index].buf[buffer_index].rate;\n}\n\n\/\/ Add padding\npadding_end::ms => now;\n\n<<< \"Done.\" >>>;\n","old_contents":"0 => int padding_start;\n4000 => int padding_end;\n2 => int instrument_buffers;\n0 => int start;\nme.sourceDir() => string base_dir;\n\n\/\/ normalize base directory\nif (base_dir.charAt(base_dir.length()-1) != '\/')\n{\n \"\/\" +=> base_dir;\n}\n\n\/\/ instrument object\nclass Instrument {\n string filename;\n SndBuf buf[8];\n int plays;\n}\n\n\/\/ data files\nbase_dir + \"data\/ck_instruments.csv\" => string instruments_file;\nbase_dir + \"data\/ck_sequence.csv\" => string sequence_file;\n\n\/\/ read data files\nFileIO instruments_fio;\nFileIO sequence_fio;\ninstruments_fio.open( instruments_file, FileIO.READ );\nsequence_fio.open( sequence_file, FileIO.READ );\n\n\/\/ check if files are valid\nif( !instruments_fio.good() || !sequence_fio.good() )\n{\n cherr <= \"can't open instrument and\/or sequence files for reading...\"\n <= IO.newline();\n me.exit();\n}\n\n\/\/ create instruments array\nInstrument instruments[256];\n\n\/\/ read instruments file\nwhile( instruments_fio.more() )\n{\n \/\/ read instrument index and filename\n Std.atoi(instruments_fio.readLine()) => int instrument_index;\n instruments_fio.readLine() => string filename;\n filename.find(\"\\r\") => int return_match;\n if (return_match >= 0)\n {\n filename.erase(return_match, 1);\n }\n base_dir + filename => instruments[instrument_index].filename;\n 0 => instruments[instrument_index].plays;\n \/\/ create buffers from filename\n for( 0 => int i; i < instrument_buffers; i++ )\n {\n instruments[instrument_index].filename => instruments[instrument_index].buf[i].read;\n \/\/ set position to end, so it won't play immediately upon open\n instruments[instrument_index].buf[i].samples() => instruments[instrument_index].buf[i].pos;\n instruments[instrument_index].buf[i] => dac;\n }\n\n}\n\n\n\/\/ Add padding\npadding_start::ms => now;\npadding_start => int elapsed_ms;\n\n\/\/ read sequence from file\nwhile( sequence_fio.more() ) {\n Std.atoi(sequence_fio.readLine()) => int instrument_index;\n Std.atoi(sequence_fio.readLine()) => int position;\n Std.atof(sequence_fio.readLine()) => float gain;\n Std.atof(sequence_fio.readLine()) => float rate;\n Std.atoi(sequence_fio.readLine()) => int milliseconds;\n\n elapsed_ms + milliseconds => elapsed_ms;\n if (start > elapsed_ms)\n {\n continue;\n }\n\n \/\/ wait duration\n\tif (milliseconds > 0)\n {\n milliseconds::ms => now;\n }\n\n \/\/ choose buffer index\n instruments[instrument_index].plays % instrument_buffers => int buffer_index;\n instruments[instrument_index].plays++;\n\n \/\/ play the instrument\n position => instruments[instrument_index].buf[buffer_index].pos;\n gain => instruments[instrument_index].buf[buffer_index].gain;\n rate => instruments[instrument_index].buf[buffer_index].rate;\n}\n\n\/\/ Add padding\npadding_end::ms => now;\n\n<<< \"Done.\" >>>;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"ee4bec8a7c2ead9baeabb96a2064200253e932f2","subject":"Perlin noise working smoothly and gentlygit status","message":"Perlin noise working smoothly and gentlygit status\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"Utils\/Ken.ck","new_file":"Utils\/Ken.ck","new_contents":"\/*\n* One dimensional Perlin Noise implementation based on:\n* http:\/\/freespace.virgin.net\/hugo.elias\/models\/m_perlin.htm\n*\n* Usage: \n* next() --> get next perlin noise values\n*\n* Getters and setters and provided for:\n* seed --> where to start from\n* delta --> how far the next value lies\n* octaves --> how many noise functions to be used\n* persistence --> harshness of the amp\/freq computation \n*\/\n\npublic class Ken\n{\n int _octaves;\n float _persistence;\n float _seed;\n float _delta;\n\n \/\/ constructor\n {\n 5 => _octaves;\n 0.25 => _persistence;\n\n ( 0.0, 200.0 ) => Std.rand2f => seed;\n 0.01 => delta;\n }\n\n \/\/ resturns next perlin noise value\n fun float next()\n {\n float result;\n\n _perlin_noise( seed ) => result;\n seed + delta => seed;\n \n return result;\n }\n\n \/\/\n \/\/ setters and getters section\n\n \/\/ delta setter\n fun float delta( float new_delta )\n {\n new_delta => _delta;\n\n return _delta;\n }\n\n \/\/ delta getter\n fun float delta()\n {\n return _delta;\n }\n\n \/\/ seed setter\n fun float seed( float new_seed )\n {\n new_seed => _seed;\n\n return _seed;\n }\n\n \/\/ seed getter\n fun float seed()\n {\n return _seed;\n }\n\n \/\/ octaves setter\n fun float octaves( float new_octaves )\n {\n new_octaves => _octaves;\n\n return _octaves;\n }\n\n \/\/ octaves getter\n fun float octaves()\n {\n return _octaves;\n }\n\n \/\/ persistence setter\n fun float persistence( float new_persistence )\n {\n new_persistence => _persistence;\n\n return _persistence;\n }\n\n \/\/ persostence getter\n fun float persistence()\n {\n return _persistence;\n }\n\n\n \/\/\n \/\/ perlin noise implementation\n \/\/ this should be a private section\n\n \/\/ pseudo random number generator\n fun float _simple_noise( int x )\n {\n (( x << 13 ) ^ x ) => x;\n return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) \/ 1073741824.0);\n }\n\n \/\/ cosine interpolation\n fun float _cos_interpolation( float a, float b, float x )\n {\n float ft;\n float f;\n \n x * pi => ft;\n ( 1 - Math.cos( ft )) * 0.5 => f;\n\n return a * (1-f) + b * f;\n }\n\n \/\/ smooting the psude random noise\n fun float _smooth_noise( int x )\n {\n float result;\n \n _simple_noise( x ) \/ 2.0 => result;\n _simple_noise( x-1 ) \/ 4.0 +=> result;\n _simple_noise( x+1 ) \/ 4.0 +=> result;\n\n return result;\n }\n\n \/\/ noise cosine interpolation\n fun float _interpolated_noise( float x )\n {\n int integer;\n float fractorial;\n float v1, v2;\n \n x $ int => integer;\n x - integer => fractorial;\n\n _smooth_noise( integer ) => v1;\n _smooth_noise( integer+1 ) => v2;\n\n return _cos_interpolation( v1, v2, fractorial );\n }\n\n \/\/ actual perlin noise algorithm\n fun float _perlin_noise( float x )\n {\n float total;\n float persistence;\n float amp, freq;\n int octaves;\n\n 0.0 => total;\n 0.25 => persistence;\n 5 => octaves;\n \n for( 0 => int i; i < octaves-1; i++ )\n {\n Math.pow( 2, i ) => freq;\n Math.pow( persistence, i ) => amp;\n\n _interpolated_noise( x * freq ) * amp +=> total;\n }\n\n return total;\n }\n}","old_contents":"\/*\n* --------------> WARNING <--------------\n* This is a sketch for the class implementing \n* one dimentional perlin noise\n* it's a code taken from Processing source repo\n* and re-written to ChucK. Unfortunatelly\n* it doesn't work well, so needs some testing\n*\/\n\npublic class Ken\n{\n\n 4 => int PERLIN_YWRAPB;\n ( 1 << PERLIN_YWRAPB ) => int PERLIN_YWRAP;\n 8 => int PERLIN_ZWRAPB;\n ( 1 << PERLIN_ZWRAPB ) => int PERLIN_ZWRAP;\n 4095 => int PERLIN_SIZE;\n\n 4 => int perlin_octaves; \/\/ default to medium smooth\n 0.5 => float perlin_amp_falloff; \/\/ 50% reduction\/octave\n\n 0.5 => float SINCOS_PRECISION;\n ( 360 \/ SINCOS_PRECISION ) $ int => int SINCOS_LENGTH;\n\n SINCOS_LENGTH => int perlin_TWOPI => int perlin_PI;\n ( perlin_PI >> 1 ) => perlin_PI;\n float perlin_cosTable[ SINCOS_LENGTH ];\n float perlin[ PERLIN_SIZE + 1 ];\n\n\n { \/\/ CONSTRUCTOR\n for( 0 => int i; i < SINCOS_LENGTH; i++ ) \n {\n Math.cos( i * ( Math.PI \/ 180.0 ) * SINCOS_PRECISION ) => perlin_cosTable[ i ];\n }\n }\n\n\n fun float noise( float x ) \n {\n return noise( x, 0.0, 0.0 );\n }\n\n\n fun float noise( float x, float y ) \n {\n return noise( x, y, 0.0 );\n }\n\n\n fun float noise( float x, float y, float z ) \n {\n if( perlin == NULL ) \n {\n for( 0 => int i; i < PERLIN_SIZE + 1; i++) \n {\n Std.randf() => perlin[ i ]; \n }\n }\n\n if( x < 0 ) \n -x => x;\n if( y < 0 ) \n -y => y;\n if( z < 0 ) \n -z => z;\n\n x $ int => int xi; \n y $ int => int yi; \n z $ int => int zi; \n\n ( x - xi ) $ float => float xf; \n ( y - yi ) $ float => float yf; \n ( z - zi ) $ float => float zf; \n\n float rxf, ryf;\n\n 0.0 => float r;\n 0.5 => float ampl;\n\n float n1, n2, n3;\n\n for( 0 => int i; i < perlin_octaves; i++ ) \n {\n xi + ( yi << PERLIN_YWRAPB ) + ( zi << PERLIN_ZWRAPB ) => int of;\n\n noise_fsc( xf ) => rxf;\n noise_fsc( yf ) => ryf;\n\n perlin[ of & PERLIN_SIZE ] => n1;\n rxf * ( perlin[ ( of + 1 ) & PERLIN_SIZE ] - n1 ) +=> n1;\n perlin[ ( of + PERLIN_YWRAP ) & PERLIN_SIZE ] => n2;\n rxf * ( perlin[ ( of + PERLIN_YWRAP + 1 ) & PERLIN_SIZE ] - n2) +=> n2;\n ryf*(n2-n1) +=> n1;\n\n PERLIN_ZWRAP +=> of;\n perlin[ of & PERLIN_SIZE ] => n2;\n rxf * ( perlin[ ( of + 1 ) & PERLIN_SIZE ] - n2 ) +=> n2;\n perlin[ ( of + PERLIN_YWRAP ) & PERLIN_SIZE ] => n3;\n rxf * ( perlin[ ( of + PERLIN_YWRAP + 1 ) & PERLIN_SIZE ] - n3 ) +=> n3;\n ryf * ( n3 - n2 ) +=> n2;\n\n noise_fsc( zf ) * ( n2 - n1 ) +=> n1;\n\n n1 * ampl +=> r;\n perlin_amp_falloff *=> ampl;\n xi << 1 => xi; \n 2 *=> xf;\n yi << 1 => yi; \n 2 *=> yf;\n zi << 1 => zi; \n 2 *=> zf;\n\n if( xf >= 1.0 ) \n { \n xi++; \n 1.0 -=> xf; \n }\n if( yf >= 1.0 ) \n { \n yi++; \n 1.0 -=> yf; \n }\n if( zf >= 1.0 ) \n { \n zi++; \n 1.0 -=> zf; \n }\n }\n return r;\n }\n\n\n fun float noise_fsc(float i) \n {\n \/\/ using bagel's cosine table instead\n return 0.5 * ( 1.0 - perlin_cosTable[ ( ( i * perlin_PI ) % perlin_TWOPI ) $ int ] );\n }\n\n}","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"ChucK"} {"commit":"9c426ae9515adcf444075a827016cb35d7a1ce5a","subject":"Update bassdrum_electronic_deepboom2.ck","message":"Update bassdrum_electronic_deepboom2.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electronic_deepboom2.ck","new_file":"patches\/percussion\/bassdrum_electronic_deepboom2.ck","new_contents":"public class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 970, -5.98, .24, 104,-3.3, 1.8, 41.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 540::ms, 0.0, 125::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 281::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n Dyno comp => bdmast;\n comp.compress();\n SinOsc form => volE => LPF boom => PoleZero dc => comp; \n dc.blockZero(0.994);\n 132 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(.22);\n 21::samp => now;\n\n \/\/ advance time\n if (now > (start + 250::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\nKickSynC kick1;\n\nkick1.bdmast => dac;\nkick1.trigger(4.4);\n\n1::second => now;\n\n","old_contents":"\/\/ Assignment 7 drumCircleDSP\npublic class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 970, -5.98, .24, 104,-3.3, 1.8, 41.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 540::ms, 0.0, 125::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 281::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n Dyno comp => bdmast;\n comp.compress();\n SinOsc form => volE => LPF boom => PoleZero dc => comp; \n dc.blockZero(0.994);\n 132 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(.22);\n 21::samp => now;\n\n \/\/ advance time\n if (now > (start + 250::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\nKickSynC kick1;\n\nkick1.bdmast => dac;\nkick1.trigger(4.4);\n\n1::second => now;\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"a810c4bfa92c4cc2be6088e5d00bc61e7d724e1b","subject":"took out gravity hum.","message":"took out gravity hum.\n","repos":"jordanorelli\/wii-chuck-synth","old_file":"resin_run.ck","new_file":"resin_run.ck","new_contents":"OscRecv wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float rawGain;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\/\/ ToneCalc.grid(8, 8, 1, 5, 82.4068867, 12.0) @=> float toneMap[][];\nToneCalc.grid(8, 8, 1, 5, 55.0, 12.0) @=> float toneMap[][];\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 55.0, 12.0) @=> oscBank;\n\n if(prompt)\n {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n\n Launchpad.Launchpad(lpChannel) @=> lp;\n }\n else\n {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone)\n {\n return;\n }\n\n if(toneChoice == 0)\n {\n oscBank.setPatch(\"SinOsc\");\n }\n else if(toneChoice == 1)\n {\n oscBank.setPatch(\"SqrOsc\");\n }\n else if(toneChoice == 2)\n {\n oscBank.setPatch(\"SawOsc\");\n }\n else if(toneChoice == 3)\n {\n oscBank.setPatch(\"TriOsc\");\n }\n else\n {\n return;\n }\n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void sostenutoOn()\n{\n true => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sostenutoStatus[i][j];\n }\n }\n }\n}\n\nfun void sostenutoOff()\n{\n false => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sostenutoStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void sustainOn()\n{\n true => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sustainStatus[i][j];\n }\n }\n }\n}\n\nfun void sustainOff()\n{\n false => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sustainStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n rawGain => targetGain;\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\nfun void sustainListener()\n{\n wm.event(\"\/wii\/1\/button\/B,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sustainOff();\n }\n else\n {\n sustainOn();\n }\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sostenutoOff();\n }\n else\n {\n sostenutoOn();\n }\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n Math.max(0.0, e.getFloat() - 0.22) => rawGain;\n \/\/ chout <= rawGain <= IO.newline();\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true)\n {\n 1::second => now;\n }\n}\n\nsetup();\n\nwhile(true)\n{\n 100::ms => now;\n}\n","old_contents":"OscRecv wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float rawGain;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\/\/ ToneCalc.grid(8, 8, 1, 5, 82.4068867, 12.0) @=> float toneMap[][];\nToneCalc.grid(8, 8, 1, 5, 55.0, 12.0) @=> float toneMap[][];\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 55.0, 12.0) @=> oscBank;\n\n if(prompt)\n {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n\n Launchpad.Launchpad(lpChannel) @=> lp;\n }\n else\n {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone)\n {\n return;\n }\n\n if(toneChoice == 0)\n {\n oscBank.setPatch(\"SinOsc\");\n }\n else if(toneChoice == 1)\n {\n oscBank.setPatch(\"SqrOsc\");\n }\n else if(toneChoice == 2)\n {\n oscBank.setPatch(\"SawOsc\");\n }\n else if(toneChoice == 3)\n {\n oscBank.setPatch(\"TriOsc\");\n }\n else\n {\n return;\n }\n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void sostenutoOn()\n{\n true => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sostenutoStatus[i][j];\n }\n }\n }\n}\n\nfun void sostenutoOff()\n{\n false => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sostenutoStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void sustainOn()\n{\n true => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sustainStatus[i][j];\n }\n }\n }\n}\n\nfun void sustainOff()\n{\n false => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sustainStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n rawGain => targetGain;\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\n\/\/ fun void wiiParser(MidiMsg msg)\n\/\/ {\n\/\/ if(msg.data1 == 176) \/\/ midi CC\n\/\/ {\n\/\/ if(msg.data2 == 64)\n\/\/ { \/\/ wiimote acceleration\n\/\/ msg.data3 => rawGain;\n\/\/ }\n\/\/ else if (msg.data2 == 65)\n\/\/ { \/\/ wiimote button b\n\/\/ if(msg.data3 == 127)\n\/\/ {\n\/\/ sustainOn();\n\/\/ }\n\/\/ else\n\/\/ {\n\/\/ sustainOff();\n\/\/ }\n\/\/ }\n\/\/ else if (msg.data2 == 66)\n\/\/ { \/\/ wiimote button a\n\/\/ if(msg.data3 == 127)\n\/\/ {\n\/\/ sostenutoOn();\n\/\/ }\n\/\/ else\n\/\/ {\n\/\/ sostenutoOff();\n\/\/ }\n\/\/ }\n\/\/ }\n\/\/ }\n\nfun void sustainListener()\n{\n wm.event(\"\/wii\/1\/button\/B,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sustainOff();\n }\n else\n {\n sustainOn();\n }\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sostenutoOff();\n }\n else\n {\n sostenutoOn();\n }\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n e.getFloat() => rawGain;\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true)\n {\n 1::second => now;\n }\n}\n\nsetup();\n\nwhile(true)\n{\n 100::ms => now;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"8ca198d5d4ea40e6b937f8230653146d445cf7b0","subject":"Add some chords","message":"Add some chords\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\",\"IIdim\",\"IIaug\",\"IIsus4\",\"II7\",\"ii7\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"iv\"],\n [\"bV\",\"bv\",\"bVdim\",\"bVaug\",\"bVsus4\",\"bV7\",\"bv7\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n if (type==6)\n {\n [root,root+3,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\nclass IntList\n{\n 0=>int size;\n IntNode @ first;\n IntNode @ last;\n \n fun void offer(int o)\n {\n IntNode n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun int poll()\n {\n if (size==0)\n return -1;\n size--;\n first @=> IntNode n;\n n.next @=> first;\n return n.object;\n }\n}\nclass IntNode\n{\n int object;\n IntNode @ next;\n fun void init(int o)\n {\n o=>object;\n }\n}\nclass LinkedList \/\/great pain to write a linked list in chuck\n{\n 0=>int size;\n Node @ first;\n Node @ last;\n \n fun void offer(Object o)\n {\n Node n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun Object poll()\n {\n if (size==0)\n return null;\n size--;\n first @=> Node n;\n n.next @=> first;\n return n.object;\n }\n fun Object add(Object o[])\n {\n for (0=>int i; iobject;\n }\n}\n\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord IIdim;\nChord ii7;\nChord iii;\nChord III;\nChord bv7;\nChord IV;\nChord iv;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi,ii7],[[0.1,0.1,0.1,0.3,0.2,0.1,0.1],[0.1,0.1,0.1,0.1,0.1,0.4,0.1]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[iii,III,V,vi],[[0.2,0.3,0.4,0.1],[0.4,0.3,0.2,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\nIIdim.init(2,2,[V],[[1.0],[1.0]]);\nii7.init(2,6,[I,V],[[0.3,0.7],[0.3,0.7]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi,iv],[[0.5,0.3,0.2],[0.2,0.6,0.2]]);\nIV.init(5,0,[I,V,V7,III,bv7],[[0.3,0.3,0.2,0.1,0.1],[0.2,0.4,0.1,0.2,0.1]]);\niv.init(5,1,[VI,V,vi],[[0.3,0.4,0.3],[0.2,0.4,0.4]]);\nbv7.init(6,6,[V],[[1.0],[1.0]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V,IIdim],[[0.2,0.2,0.1,0.3,0.1,0.1],[0.2,0.2,0.2,0.2,0.1,0.1]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI],[[1.0],[1.0]]);\nIII.setModulation([[VIsus4]],[-3],[I]);\nI.setModulation([[VI],[I7],[VI]],[2,5,7],[I,I,V]);\nRhodey instruments[4];\nIntList beats;\nIntList keys;\nLinkedList chords;\nchords.offer(IV);\nkeys.offer(3);\nbeats.offer(4);\n0=>int rhythmCounter;\nfun void generateChords()\n{\n chords.getLast() $ Chord @=> Chord lastChord;\n if (lastChord.getModulationSequence()!=null && Math.random2f(0, 1)<0.2)\n {\n lastChord.getModulationSequence()@=>Chord modSqs[][];\n lastChord.getModulationTarget()@=>int modKeys[];\n lastChord.getModulationChord()@=>Chord targetChords[];\n Math.random2f(0,modSqs.cap()) $ int =>int choice;\n modSqs[choice]@=>Chord modSq[];\n modKeys[choice]=>int keyChange;\n targetChords[choice]@=>Chord targetChord;\n for (0=>int i; i float p;\n if (p<=0.6)\n {\n beats.offer(4);\n }\n else if (p<=0.7)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(2);\n }\n else if (p<=0.8)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n }\n else if (p<=0.9)\n {\n beats.offer(6);\n beats.offer(2);\n }\n else\n {\n beats.offer(3);\n beats.offer(2);\n beats.offer(3);\n }\n}\n\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n\nfun void playChord(Chord current, int key, int beat)\n{\n if (beats.size==0)\n {\n generateBeats();\n }\n current.root=>int root;\n current.type=>int type;\n send.startMsg(\"\/key\/root\/type\", \"i i i\");\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n current.getNotesWithin()@=>int notes[];\n <<< \"Chord Name: \", current.toString() >>>;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n <<< \"Beats Played: \", beat>>>;\n for (0=>int j;jnow;\n float dyn;\n if (rhythmCounter == 0)\n 0.2=>dyn;\n else if (rhythmCounter == 2)\n 0.11=>dyn;\n else\n 0.07=>dyn;\n Std.mtof(36+(key+notes[0]%12))=>instruments[0].freq;\n dyn=>instruments[0].noteOn;\n for (1=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n dyn=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n dyn=>instruments[i].noteOn;\n }\n <<<\"beat: \", rhythmCounter>>>;\n (rhythmCounter+1)%4=>rhythmCounter;\n }\n}\nwhile (true)\n{\n if (chords.size<5)\n { \n generateChords();\n }\n if (beats.size<5)\n { \n generateBeats;\n }\n playChord(chords.poll()$Chord, keys.poll(), beats.poll());\n}\n\n\n","old_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"iv\"],\n [\"bV\",\"bv\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\nclass IntList\n{\n 0=>int size;\n IntNode @ first;\n IntNode @ last;\n \n fun void offer(int o)\n {\n IntNode n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun int poll()\n {\n if (size==0)\n return -1;\n size--;\n first @=> IntNode n;\n n.next @=> first;\n return n.object;\n }\n}\nclass IntNode\n{\n int object;\n IntNode @ next;\n fun void init(int o)\n {\n o=>object;\n }\n}\nclass LinkedList \/\/great pain to write a linked list in chuck\n{\n 0=>int size;\n Node @ first;\n Node @ last;\n \n fun void offer(Object o)\n {\n Node n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun Object poll()\n {\n if (size==0)\n return null;\n size--;\n first @=> Node n;\n n.next @=> first;\n return n.object;\n }\n fun Object add(Object o[])\n {\n for (0=>int i; iobject;\n }\n}\n\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord iii;\nChord III;\nChord IV;\nChord iv;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi],[[0.1,0.1,0.1,0.3,0.3,0.1],[0.1,0.1,0.1,0.1,0.1,0.5]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[iii,III,V,vi],[[0.2,0.3,0.4,0.1],[0.4,0.3,0.2,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi,iv],[[0.5,0.3,0.2],[0.2,0.6,0.2]]);\nIV.init(5,0,[I,V,V7,III],[[0.3,0.4,0.2,0.1],[0.2,0.4,0.1,0.3]]);\niv.init(5,1,[VI,V,vi],[[0.3,0.4,0.3],[0.2,0.4,0.4]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V],[[0.2,0.3,0.1,0.3,0.1],[0.2,0.2,0.2,0.2,0.2]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI],[[1.0],[1.0]]);\nIII.setModulation([[VIsus4]],[-3],[I]);\nI.setModulation([[VI],[I7],[VI]],[2,5,7],[I,I,V]);\nRhodey instruments[4];\nIntList beats;\nIntList keys;\nLinkedList chords;\nchords.offer(I);\nkeys.offer(3);\nbeats.offer(4);\n0=>int rhythmCounter;\nfun void generateChords()\n{\n chords.getLast() $ Chord @=> Chord lastChord;\n if (lastChord.getModulationSequence()!=null && Math.random2f(0, 1)<0.2)\n {\n lastChord.getModulationSequence()@=>Chord modSqs[][];\n lastChord.getModulationTarget()@=>int modKeys[];\n lastChord.getModulationChord()@=>Chord targetChords[];\n Math.random2f(0,modSqs.cap()) $ int =>int choice;\n modSqs[choice]@=>Chord modSq[];\n modKeys[choice]=>int keyChange;\n targetChords[choice]@=>Chord targetChord;\n for (0=>int i; i float p;\n if (p<=0.6)\n {\n beats.offer(4);\n }\n else if (p<=0.7)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(2);\n }\n else if (p<=0.8)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n }\n else if (p<=0.9)\n {\n beats.offer(6);\n beats.offer(2);\n }\n else\n {\n beats.offer(3);\n beats.offer(2);\n beats.offer(3);\n }\n}\n\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n\nfun void playChord(Chord current, int key, int beat)\n{\n if (beats.size==0)\n {\n generateBeats();\n }\n current.root=>int root;\n current.type=>int type;\n send.startMsg(\"\/key\/root\/type\", \"i i i\");\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n current.getNotesWithin()@=>int notes[];\n <<< \"Chord Name: \", current.toString() >>>;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n <<< \"Beats Played: \", beat>>>;\n for (0=>int j;jnow;\n float dyn;\n if (rhythmCounter == 0)\n 0.2=>dyn;\n else if (rhythmCounter == 2)\n 0.11=>dyn;\n else\n 0.07=>dyn;\n Std.mtof(36+(key+notes[0]%12))=>instruments[0].freq;\n dyn=>instruments[0].noteOn;\n for (1=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n dyn=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n dyn=>instruments[i].noteOn;\n }\n <<<\"beat: \", rhythmCounter>>>;\n (rhythmCounter+1)%4=>rhythmCounter;\n }\n}\nwhile (true)\n{\n if (chords.size<5)\n {\n generateChords();\n }\n if (beats.size<5)\n {\n generateBeats;\n }\n playChord(chords.poll()$Chord, keys.poll(), beats.poll());\n}\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"128e53f6a46335e21d7c504c192aa3e58b513292","subject":"Removed the multi stream from master","message":"Removed the multi stream from master\n","repos":"DataOnAcid\/AudioRenderer,DataOnAcid\/AudioRenderer","old_file":"dataacid.ck","new_file":"dataacid.ck","new_contents":"\/*\nData on Acid hack\n\nIain Emsley\n\nSSI hack March 2015\n\n*\/\n\nFlute flute => PoleZero f => JCRev r => dac;\n.8 => r.gain;\n.05 => r.mix;\n.99 => f.blockZero;\n\n.2 => float timeSt;\n\/\/recording\ndac => Gain g => WvOut w => blackhole;\n\n\/\/ print out all arguments\nme.arg(0) => string original;\nme.arg(1) => string outname;\n\nint texta[5000];\n\nint size;\n\/\/create the array and push into a variable\nreadInts(original) @=> texta;\n\noutname => w.wavFilename;\n\n\/\/ any gain you want for the output\n.5 => g.gain;\n\n\/\/start recording\n1 => w.record;\n\nfor (0 => int i; i w.record;\n\n\/\/ temporary workaround to automatically close file on remove-shred\nnull @=> w;\n\n\/\/ play the note\n\/\/ play the note\nfun void play(Flute flute, int note, float velocity) {\n \/\/ start the note\n Std.mtof( note ) => flute.freq;\n velocity => flute.noteOn;\n .6 => flute.gain;\n 100::ms => now;\n velocity => flute.noteOff;\n \n}\n\n\/\/ read the ints into an array\n\/\/ http:\/\/wiki.cs.princeton.edu\/index.php\/ChucK\/Dev\/IO\/FileIO\nfun int[] readInts(string path) {\n \n \/\/ open the file\n FileIO file;\n if (!file.open(path, FileIO.READ)) {\n <<< \"file read failed\" >>>;\n <<< path >>>;\n int ret[0]; \/\/ error opening the specified file\n return ret;\n }\n \n \/\/ read the size of the array\n file => size;\n \/\/ now read in the contents\n int ret[size];\n for (0 => int i; i < size; i++) \n file => ret[i];\n\n file.close(); \n return ret; \n}\n","old_contents":"\/*\nData on Acid hack\n\nIain Emsley\n\nSSI hack March 2015\n\n*\/\n\nFlute flute => Pan2 p => PoleZero f => JCRev r => dac;\n.8 => r.gain;\n.05 => r.mix;\n.99 => f.blockZero;\n\n.2 => float timeSt;\n\/\/recording\ndac => Gain g => WvOut w => blackhole;\n\n\/\/ print out all arguments\nme.arg(0) => string original;\nme.arg(1) => string copy;\nme.arg(2) => string outname;\n\nint texta[5000];\nint textb[5000];\nint size;\n\/\/create the array and push into a variable\nreadInts(original) @=> texta;\nreadInts(copy) @=> textb;\n\noutname => w.wavFilename;\n\n\/\/ any gain you want for the output\n.5 => g.gain;\n\n\/\/start recording\n1 => w.record;\n\nfor (0 => int i; i w.record;\n\n\/\/ temporary workaround to automatically close file on remove-shred\nnull @=> w;\n\n\/\/ play the note\n\/\/ play the note\nfun void play(Flute flute, int note, float velocity, Pan2 p, float textpan) {\n \/\/ start the note\n Std.mtof( note ) => flute.freq;\n velocity => flute.noteOn;\n .6 => flute.gain;\n textpan => p.pan;\n 100::ms => now;\n velocity => flute.noteOff;\n \n}\n\n\/\/ read the ints into an array\n\/\/ http:\/\/wiki.cs.princeton.edu\/index.php\/ChucK\/Dev\/IO\/FileIO\nfun int[] readInts(string path) {\n \n \/\/ open the file\n FileIO file;\n if (!file.open(path, FileIO.READ)) {\n <<< \"file read failed\" >>>;\n <<< path >>>;\n int ret[0]; \/\/ error opening the specified file\n return ret;\n }\n \n \/\/ read the size of the array\n file => size;\n \/\/ now read in the contents\n int ret[size];\n for (0 => int i; i < size; i++) \n file => ret[i];\n\n file.close(); \n return ret; \n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"ChucK"} {"commit":"54b833a4263cffef8fd45037d67ea9a1dac62d26","subject":"add greeter function","message":"add greeter function\n","repos":"pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds","old_file":"chuck\/hello.ck","new_file":"chuck\/hello.ck","new_contents":"\nfun string greeter( string a )\n{\n <<< \"Hello \" + a >>>;\n}\n\ngreeter(\"DevFest\") => string greet;","old_contents":"\n\"monkey\" => string name;\n<<< \"hello \" + name >>>;","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"1e66eb9745c0397d0aae7eefb49fac3555e6cbf1","subject":"Update to_stereo_wav_with_gainParams.ck","message":"Update to_stereo_wav_with_gainParams.ck\n\nadded gain possibility.","repos":"zeffii\/ChucKScripts","old_file":"wave_writer\/to_stereo_wav_with_gainParams.ck","new_file":"wave_writer\/to_stereo_wav_with_gainParams.ck","new_contents":"\/\/me.arg(0) => string filename;\n\/\/if( filename.length() == 0 ) \"foo.wav\" => filename;\n\ndac => Mix2 regulator => WvOut2 w => blackhole;\n\/\/\"data\/session\" => w.autoPrefix;\n\nregulator.gain(1.0);\n\"woooot.wav\" => w.wavFilename;\n1 => w.record;\n3::second => now;\n\n\/\/ everything in between gets recorded.\n\n\n0 => w.record;\n","old_contents":"\/\/me.arg(0) => string filename;\n\/\/if( filename.length() == 0 ) \"foo.wav\" => filename;\n\ndac => WvOut2 w => blackhole;\n\/\/\"data\/session\" => w.autoPrefix;\n\"woooot.wav\" => w.wavFilename;\n1 => w.record;\n3::second => now;\n\n\/\/ everything in between\n\n\n0 => w.record;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"9c13449700ebfaa882fe80cc31f1ebc0bc97d318","subject":"Better debug info printing","message":"Better debug info printing\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"test\/stammer_test.ck","new_file":"test\/stammer_test.ck","new_contents":"<<< \">>> Testing Stammer class\", \"\">>>;\n\n<<< \">>> Loading class\", \"\">>>;\nStammer stm => dac;\n2.0 => stm.set_freq;\nspork ~ stm.on();\n\n<<< \">>> Loading audio files\", \"\">>>;\nSndBuf buf_1;\nSndBuf buf_2;\nme.dir() + \"\/..\/sounds\/test_sound_01.wav\" => buf_1.read;\nme.dir() + \"\/..\/sounds\/test_sound_02.wav\" => buf_2.read;\n\n<<< \">>> Running test\", \"\">>>;\nbuf_2 => stm;\n10::second => now;\n\nbuf_2 =< stm;\nbuf_1 => stm;\n10::second => now;\n\nbuf_2 => stm;\n10::second => now;\n","old_contents":"<<< \"Testing Stammer class\" >>>;\n\n<<< \"Loading class\" >>>;\nStammer stm => dac;\n2.0 => stm.set_freq;\nspork ~ stm.on();\n\n<<< \"Loading audio files\" >>>;\nSndBuf buf_1;\nSndBuf buf_2;\nme.dir() + \"\/..\/sounds\/test_sound_01.wav\" => buf_1.read;\nme.dir() + \"\/..\/sounds\/test_sound_02.wav\" => buf_2.read;\n\n<<< \"Running test\" >>>;\nbuf_2 => stm;\n10::second => now;\n\nbuf_2 =< stm;\nbuf_1 => stm;\n10::second => now;\n\nbuf_2 => stm;\n10::second => now;\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"ChucK"} {"commit":"8513ac8b56d57b2cef445ba66eadc60f218dcd1b","subject":"created instrument object, added instrument buffers","message":"created instrument object, added instrument buffers\n","repos":"beefoo\/music-lab-scripts,beefoo\/music-lab-scripts,beefoo\/music-lab-scripts,shawngraham\/music-lab-scripts,rblades\/music-lab-scripts","old_file":"01_subway\/subway.ck","new_file":"01_subway\/subway.ck","new_contents":"2000 => int padding;\n2 => int instrument_buffers;\n\n\/\/ instrument object\nclass Instrument { \n string filename;\n SndBuf buf[8];\n int plays;\n}\n\n\/\/ data files\nme.sourceDir() + \"\/data\/ck_instruments.csv\" => string instruments_file;\nme.sourceDir() + \"\/data\/ck_sequence.csv\" => string sequence_file;\n\n\/\/ read data files\nFileIO instruments_fio;\nFileIO sequence_fio;\ninstruments_fio.open( instruments_file, FileIO.READ );\nsequence_fio.open( sequence_file, FileIO.READ );\n\n\/\/ check if files are valid\nif( !instruments_fio.good() || !sequence_fio.good() )\n{\n cherr <= \"can't open instrument and\/or sequence files for reading...\"\n <= IO.newline();\n me.exit();\n}\n\n\/\/ create instruments array\nInstrument instruments[128];\n\n\/\/ read instruments file\nwhile( instruments_fio.more() )\n{\n \/\/ read instrument index and filename\n Std.atoi(instruments_fio.readLine()) => int instrument_index;\n me.sourceDir() + \"\/\" + instruments_fio.readLine() => instruments[instrument_index].filename;\n 0 => instruments[instrument_index].plays;\n \/\/ create buffers from filename\n for( 0 => int i; i < instrument_buffers; i++ )\n {\n instruments[instrument_index].filename => instruments[instrument_index].buf[i].read;\n \/\/ set position to end, so it won't play immediately upon open\n instruments[instrument_index].buf[i].samples() => instruments[instrument_index].buf[i].pos;\n instruments[instrument_index].buf[i] => dac;\n }\n \n}\n\n\n\/\/ Add padding\npadding::ms => now;\n\n\/\/ read sequence from file\nwhile( sequence_fio.more() ) { \n Std.atoi(sequence_fio.readLine()) => int instrument_index;\n Std.atoi(sequence_fio.readLine()) => int position;\n Std.atof(sequence_fio.readLine()) => float gain;\n Std.atof(sequence_fio.readLine()) => float rate;\n Std.atoi(sequence_fio.readLine()) => int milliseconds;\n \n \/\/ wait duration\n\tif (milliseconds > 0)\n {\n milliseconds::ms => now;\n }\n \n \/\/ choose buffer index\n instruments[instrument_index].plays % instrument_buffers => int buffer_index;\n instruments[instrument_index].plays++;\n\t\n \/\/ play the instrument\n position => instruments[instrument_index].buf[buffer_index].pos;\n gain => instruments[instrument_index].buf[buffer_index].gain;\n rate => instruments[instrument_index].buf[buffer_index].rate;\n}\n\n\/\/ Add padding\npadding::ms => now;\n\n<<< \"Done.\" >>>;\n\n","old_contents":"2000 => int padding;\n\n\/\/ data files\nme.sourceDir() + \"\/data\/ck_instruments.csv\" => string instruments_file;\nme.sourceDir() + \"\/data\/ck_sequence.csv\" => string sequence_file;\n\n\/\/ read data files\nFileIO instruments_fio;\nFileIO sequence_fio;\ninstruments_fio.open( instruments_file, FileIO.READ );\nsequence_fio.open( sequence_file, FileIO.READ );\n\n\/\/ check if files are valid\nif( !instruments_fio.good() || !sequence_fio.good() )\n{\n cherr <= \"can't open instrument and\/or sequence files for reading...\"\n <= IO.newline();\n me.exit();\n}\n\n\/\/ create instruments from file\nSndBuf instruments[120];\nwhile( instruments_fio.more() )\n{\n Std.atoi(instruments_fio.readLine()) => int instrument_index;\n me.sourceDir() + \"\/\" + instruments_fio.readLine() => string filename; \n filename => instruments[instrument_index].read;\n \/\/ set position to end, so it won't play immediately upon open\n instruments[instrument_index].samples() => instruments[instrument_index].pos;\n instruments[instrument_index] => dac;\n}\n\n\/\/ Add padding\npadding::ms => now;\n\n\/\/ read sequence from file\nwhile( sequence_fio.more() ) { \n Std.atoi(sequence_fio.readLine()) => int instrument_index;\n Std.atoi(sequence_fio.readLine()) => int position;\n Std.atof(sequence_fio.readLine()) => float gain;\n Std.atof(sequence_fio.readLine()) => float rate;\n Std.atoi(sequence_fio.readLine()) => int milliseconds;\n \n\tif (milliseconds > 0)\n {\n milliseconds::ms => now;\n }\n\t\n position => instruments[instrument_index].pos;\n gain => instruments[instrument_index].gain;\n rate => instruments[instrument_index].rate;\n}\n\n\/\/ Add padding\npadding::ms => now;\n\n<<< \"Done.\" >>>;\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"0e761ae5527dcee90bd95b6eb5a8c6ef4ab3036f","subject":"Revert \"Implementation change\"","message":"Revert \"Implementation change\"\n\nThis reverts commit 0933f1697aec78d908f17c10e2acef03b5c3641a.\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"\/* As you can see, this is a very raw Markov chain for chord progressions\n * It would be great if melodies can be generated according to this state machine\n * I use classes only because a ton of \"else if\" looks really messy, though the object-oriented of this language is really bad\n * The blank funcion is intended for future data receiving\n * It sends basic information of a chord\n * I hope melody can be generated according to the chord\n *\/\n \n\/\/the very basic chord base\nclass Chord\n{\n string name; \/\/how you call it\n string nextChord[]; \/\/next states\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probability[]; \/\/probability for each next state\n fun string getNextChordName() \/\/randomly choose the next chord\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n for (0=>int i; ic;\n if (rand<=c)\n return nextChord[i];\n }\n return this.name;\n }\n fun void setStyle(){} \/\/may be used to change probabilities\n}\n\nclass ChordMajor extends Chord\n{\n 0=>type;\n}\n\nclass ChordMinor extends Chord\n{\n 1=>type;\n}\n\nclass ChordI extends ChordMajor\n{\n \"I\"=>name;\n 0=>root;\n [\"I\", \"ii\",\"III\",\"IV\",\"V\"]@=>nextChord;\n [0.1,0.1,0.1,0.4,0.3]@=>probability;\n}\nclass Chordii extends ChordMinor\n{\n \"ii\"=>name;\n 2=>root;\n [\"I\",\"iii\",\"III\",\"V\",\"vi\"]@=>nextChord;\n [0.1,0.1,0.3,0.4,0.1]@=>probability;\n}\nclass Chordiii extends ChordMinor\n{\n \"iii\"=>name;\n 4=>root;\n [\"V\",\"IV\",\"vi\"]@=>nextChord;\n [0.2,0.4,0.4]@=>probability;\n}\nclass ChordIII extends ChordMajor\n{\n \"III\"=>name;\n 4=>root;\n [\"IV\",\"vi\"]@=>nextChord;\n [0.4,0.6]@=>probability;\n}\nclass ChordIV extends ChordMajor\n{\n \"IV\"=>name;\n 5=>root;\n [\"I\",\"V\",\"III\"]@=>nextChord;\n [0.3,0.6,0.1]@=>probability;\n}\nclass ChordV extends ChordMajor\n{\n \"V\"=>name;\n 7=>root;\n [\"I\",\"vi\",\"ii\"]@=>nextChord;\n [0.6,0.3,0.1]@=>probability;\n}class Chordvi extends ChordMinor\n{\n \"vi\"=>name;\n 9=>root;\n [\"I\",\"ii\",\"iii\",\"IV\",\"V\",\"vi\"]@=>nextChord;\n [0.1,0.3,0.1,0.3,0.1,0.1]@=>probability;\n}\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChordI I;\nChordii ii;\nChordiii iii;\nChordIII III;\nChordIV IV;\nChordV V;\nChordvi vi;\nfun Chord getChord(string s)\n{\n if (s==\"I\")\n return I;\n if (s==\"ii\")\n return ii;\n if (s==\"iii\")\n return iii;\n if (s==\"III\")\n return III;\n if (s==\"IV\")\n return IV;\n if (s==\"V\")\n return V;\n if (s==\"vi\")\n return vi;\n return null;\n}\nI @=> current;\nwhile (true)\n{\n <<< \"Chord Name: \", current.name >>>;\n 0=>int key;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n getChord(current.getNextChordName())@=>current;\n 6::second=>now;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","old_contents":"\/* As you can see, this is a very raw Markov chain for chord progressions\n * It would be great if melodies can be generated according to this state machine\n * I use classes only because a ton of \"else if\" looks really messy, though the object-oriented of this language is really bad\n * The blank funcion is intended for future data receiving\n * It sends basic information of a chord\n * I hope melody can be generated according to the chord\n *\/\n \n\/\/the very basic chord base\nclass Chord\n{\n 0=>int style;\n string name; \/\/how you call it \n Chord @ next[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getPrabablities()@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return this;\n } \n fun float[] getPrabablities()\n {\n if (style==0)\n return probabilities[0];\n }\n fun void setStyle(){} \/\/may be used to change probabilities\n}\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord ii;\nChord iii;\nChord III;\nChord IV;\nChord V;\nChord vi;\nI.init(0,0,[I,ii,III,IV,V],[[0.1,0.1,0.1,0.4,0.3]]);\nii.init(2,1,[I,iii,III,V,vi],[[0.1,0.1,0.3,0.4,0.1]]);\niii.init(4,1,[V,IV,vi],[[0.2,0.4,0.4]]);\nIII.init(4,0,[IV,vi],[[0.4,0.6]]);\nIV.init(5,0,[I,V,III],[[0.3,0.6,0.1]]);\nV.init(7,0,[I,vi,ii],[[0.6,0.3,0.1]]);\nvi.init(9,1,[I,ii,iii,IV,V,vi],[[0.1,0.3,0.1,0.3,0.1,0.1]]);\nI @=> current;\nwhile (true)\n{\n <<< \"Chord Name: \", current.name >>>;\n 0=>int key;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNextChord()@=>current;\n 6::second=>now;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"e8de9b71cc78042939aeea7eaea6bd56528e2a77","subject":"Added direct chords sound output","message":"Added direct chords sound output\n\nRunning \"chordProgression\" directly outputs the sound. Sounds cool.\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"class Chord\n{\n 0=>int style; \n Chord @ next[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(0);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return this;\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"vi\"],\n [\"bV\",\"bv\"],\n [\"V\",\"v\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun int[] getNotesWithin()\n {\n if (type==0)\n {\n return [root,root+4,root+7];\n }\n if (type==1)\n {\n return [root,root+3,root+7];\n }\n if (type==2)\n {\n return [root,root+3,root+6];\n }\n return null;\n }\n}\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord previous;\nChord current;\nChord I;\nChord ii;\nChord iii;\nChord III;\nChord IV;\nChord V;\nChord V7;\nChord vi;\nI.init(0,0,[I,ii,III,IV,V,vi],[[0.1,0.1,0.1,0.3,0.3,0.1],[0.1,0.1,0.1,0.1,0.1,0.5]]);\nii.init(2,1,[I,iii,III,V,vi],[[0.1,0.1,0.3,0.4,0.1],[0.1,0.4,0.3,0.1,0.1]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi],[[0.6,0.4],[0.3,0.7]]);\nIV.init(5,0,[I,V,III],[[0.3,0.6,0.1],[0.2,0.5,0.3]]);\nV.init(7,0,[I,vi,ii,iii],[[0.5,0.2,0.1,0.2],[0.3,0.4,0.1,0.2]]);\nvi.init(9,1,[I,ii,iii,IV,V,vi],[[0.1,0.3,0.1,0.3,0.1,0.1],[0.1,0.2,0.2,0.2,0.2,0.1]]);\nI @=> current;\nRhodey instruments[4];\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\nwhile (true)\n{\n <<< \"Chord Name: \", current.toString() >>>;\n 0=>int key;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNotesWithin()@=>int notes[];\n for (0=>int j;j<4;j++)\n { \n 0.7::second=>now;\n for (0=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+key+(notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n 0.2=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n 0.1=>instruments[i].noteOn;\n }\n }\n current.getNextChord(1)@=>Chord temp;\n while (temp==previous)\n {\n current.getNextChord(1)@=>temp;\n }\n current @=> previous;\n temp @=> current;\n}\n\n\n\n\n\n\n\n\n\n\n","old_contents":"class Chord\n{\n 0=>int style; \n Chord @ next[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities()@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return this;\n } \n fun float[] getProbabilities()\n {\n return getProbabilities(0);\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"vi\"],\n [\"bV\",\"bv\"],\n [\"V\",\"v\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n}\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord ii;\nChord iii;\nChord III;\nChord IV;\nChord V;\nChord vi;\nI.init(0,0,[I,ii,III,IV,V],[[0.1,0.1,0.1,0.4,0.3]]);\nii.init(2,1,[I,iii,III,V,vi],[[0.1,0.1,0.3,0.4,0.1]]);\niii.init(4,1,[V,IV,vi],[[0.2,0.4,0.4]]);\nIII.init(4,0,[IV,vi],[[0.4,0.6]]);\nIV.init(5,0,[I,V,III],[[0.3,0.6,0.1]]);\nV.init(7,0,[I,vi,ii],[[0.6,0.3,0.1]]);\nvi.init(9,1,[I,ii,iii,IV,V,vi],[[0.1,0.3,0.1,0.3,0.1,0.1]]);\nI @=> current;\nwhile (true)\n{\n <<< \"Chord Name: \", current.toString() >>>;\n 0=>int key;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNextChord()@=>current;\n 6::second=>now;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"e8c4a4a20bf11fa5c9ac54eb35614681def5a509","subject":"Update common_functions.ck","message":"Update common_functions.ck","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/common_functions.ck","new_file":"utility_functions\/common_functions.ck","new_contents":"\/\/ Machine.add(\"utilities.ck\");\n\n\/* \n definitions\n\n fun void repr_int_array(int arr[]){}\n fun void repr_string_array(string arr[]){}\n \n fun int random_from(int arr[]){}\n fun int inArray(int token, int arr[]){}\n fun int indexOfClosest(int ival, int arr[]){}\n fun int to_note(string str){}\n fun int[] transpose(int narray[], int semi_tones){} \n fun int[] join_int_arrays(int arr1[], int arr2[]){}\n fun int[] repeat_int_array(int arr[], int num_times){}\n fun int[] set_from(int arr[]){}\n fun int[] randomArray_from(int arr[], int length){}\n fun int[] range(int start, int end){}\n fun int[] narray(int start, int next, int up_to){}\n fun int[] expand_scale(int scale[], int start_stop[]){ \n fun int[][] stepify(string sequence_data[]){}\n \n fun float average(int arr[]){}\n \n fun string repr(int arr[]){}\n fun string repr(string arr[]){}\n fun string[] split(string arr, string token){}\n \n fun SndBuf load_sample(string wavname){}\n\n \n https:\/\/gist.github.com\/anonymous\/7206152\n \n*\/ \n\n\n\nfun string[] split_str(string str, string token){\n\n string collect[0];\n int pos;\n int pos2;\n while( str.find(token) >0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\n\nfun int[] transpose(int narray[], int semi_tones){\n int oarray[0];\n for(0 => int i; i int arr[][];\n int new_arr[0];\n for(0 => int j; j int i; i int j; j int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -5 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] join_int_arrays(int arr1[], int arr2[]){\n [arr1, arr2] @=> int arr[][];\n int new_arr[0];\n for(0 => int j; j int i; i int j; j int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -5 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i recv2.port;\nrecv2.listen();\nrecv2.event( \"\/timbre\/lifetime\/n1\/n2\/n3\/n4\/n5\/n6\/n7\/n8\/id, f i i i i i i i i i i\" ) @=> OscEvent @ om;\n\/\/ key is an integer MIDI note value (e.g., C is 0, C# is 1, etc.)\n\/\/ root is an integer MIDI note value (e.g., C is 0, C# is 1, etc.)\n\/\/ type is an integer (0 = major, 1 = minor, 2=dim, 3=aug, 4=sus4, 5=dom7)\n\nOscRecv recv;\n6450 => recv.port;\nrecv.listen();\nrecv.event( \"\/key\/root\/type, i i i\" ) @=> OscEvent @ oe;\n\nOscSend xmit;\nxmit.setHost(\"localhost\", 6452);\n\n\n0 => int key;\n0 => int root;\n0 => int type;\n600 => float portamento;\n1.5 => float detune;\n4 => int numSynths;\n0 => int activeSynth;\n0 => int activeMelSynth;\n0 => int lfoTime;\n30 => int noteDistance;\n10 => int numMelSynths;\nfloat timbre;\n\"\" => string activeid;\n[ [ [0, 2, 4, 7, 12],\n\t[1, 5, 8, 13],\n\t[0, 2, 4, 9, 12, 14],\n\t[3, 7, 10, 15],\n\t[2, 4, 8, 9, 11, 16],\n\t[0, 5, 7, 9, 12, 14],\n\t[4, 6, 10, 13],\n\t[2, 7, 9, 11, 14],\n\t[0, 3, 8, 12, 15],\n\t[4, 7, 9, 13, 14, 16],\n\t[2, 5, 9, 10, 12, 14],\n\t[-1, 6, 11, 15] ],\n [ [0, 2, 3, 5, 7, 10, 12, 15],\n\t[1, 4, 8, 13],\n\t[2, 4, 5, 9, 12, 14],\n\t[3, 5, 6, 10, 15],\n\t[4, 7, 9, 11, 14, 16],\n\t[0, 5, 7, 8, 12, 14],\n\t[6, 9, 13],\n\t[2, 6, 7, 9, 10, 12, 14],\n\t[0, 3, 8, 11, 15],\n\t[4, 9, 11, 12, 14, 16],\n\t[5, 9, 10, 12, 13],\n\t[-1, 6, 9, 11, 14] ],\n [ [0],\n [1],\n [2],\n [3],\n [4],\n [5],\n [6],\n [7],\n [8],\n [9],\n [10],\n [2, 5, 11, 14] ],\n [ [0] ],\n [ [0, 2, 5, 7, 9, 12],\n\t[1, 5, 8, 13],\n\t[2, 4, 6, 9, 12, 14],\n\t[3, 7, 10, 15],\n\t[2, 4, 8, 9, 11, 16],\n\t[0, 5, 7, 9, 12, 14],\n\t[4, 6, 10, 13],\n\t[2, 7, 9, 11, 14],\n\t[0, 3, 8, 12, 15],\n\t[4, 7, 9, 13, 14, 16],\n\t[2, 5, 9, 10, 12, 14],\n\t[-1, 6, 11, 15] ],\n [ [0, 4, 7, 10, 12],\n\t[1, 5, 8, 13],\n\t[2, 4, 6, 9, 12, 14],\n\t[3, 7, 10, 15],\n\t[2, 4, 8, 9, 11, 16],\n\t[0, 5, 7, 9, 12, 14],\n\t[4, 6, 10, 13],\n\t[2, 5, 7, 11, 12, 14],\n\t[0, 3, 8, 12, 15],\n\t[4, 7, 9, 13, 14, 16],\n\t[2, 5, 9, 10, 12, 14],\n\t[-1, 6, 11, 15] ],\n [ [0, 2, 3, 5, 7, 10, 12, 15],\n\t[1, 4, 8, 13],\n\t[0, 2, 4, 5, 9, 12, 14],\n\t[3, 5, 6, 10, 15],\n\t[2, 4, 7, 9, 11, 14, 16],\n\t[0, 5, 7, 8, 12, 14],\n\t[4, 6, 9, 13],\n\t[2, 6, 7, 9, 10, 12, 14],\n\t[0, 3, 8, 11, 15],\n\t[4, 7, 9, 11, 12, 14, 16],\n\t[5, 9, 10, 12, 13],\n\t[-1, 6, 9, 11, 14] ] ] @=> int chordNotes[][][];\n\nSawOsc bassTone => NRev bassRev => LPF bassLp => dac;\n0.04 => bassTone.gain;\n400 => bassLp.freq;\n0.3 => bassRev.mix;\n3 => bassLp.Q;\n\nTriOsc fifthTone => NRev fifthRev => LPF fifthLp => dac;\n0.03 => fifthTone.gain;\n600 => fifthLp.freq;\n0.2 => fifthRev.mix;\n2 => fifthLp.Q;\n\nTriOsc octTone => NRev octRev => LPF octLp => dac;\n0.03 => octTone.gain;\n800 => octLp.freq;\n0.2 => octRev.mix;\n2 => octLp.Q;\n\nPRCRev lrev;\nLPF lmasterLP;\n0.6 => lrev.mix;\n2000 => lmasterLP.freq;\n1 => lmasterLP.Q;\nlrev => lmasterLP => dac.left;\n\nPRCRev rrev;\nLPF rmasterLP;\n0.6 => rrev.mix;\n2000 => rmasterLP.freq;\n1 => rmasterLP.Q;\nrrev => rmasterLP => dac.right;\n\nNRev lmelrev => Dyno lmeld => dac.left;\n0.3 => lmelrev.mix;\nlmeld.limit();\nlmeld.thresh(0.16);\nNRev rmelrev => Dyno rmeld => dac.right;\n0.3 => rmelrev.mix;\nrmeld.limit();\nrmeld.thresh(0.16);\n\nSinOsc drum => LPF drumf => dac;\n1000 => drumf.freq;\n0.3 => drumf.Q;\n0 => int drumRunning;\n\nSawOsc osc[numSynths];\nADSR env[numSynths];\nLPF lp[numSynths];\nPan2 oscPan[numSynths];\nfloat lfoSpeed[numSynths];\nfloat lfoDepth[numSynths];\nSqrOsc s[numMelSynths];\nADSR e[numMelSynths];\nPan2 p[numMelSynths];\nLPF lpm[numMelSynths];\nfloat fifthNote;\nint note;\nint lifetime;\n\nfun void oscGetChord(){\n\twhile(true){\n\t\toe => now;\n\t\twhile(oe.nextMsg()){\n\t\t\t<<<\"osc recieved\">>>;\n\t\t\toe.getInt() % 12 => key;\n\t\t\toe.getInt() % 12 => root;\n\t\t\toe.getInt() => type;\n\t\t\tbassTone.freq() => float currentFreq;\n\t\t\t(root + key) % 12 + 48 => Std.mtof => float destFreq;\n\t\t\tMath.max(Math.round(portamento * Math.random2f(-0.4, 1.2)), 18) $ int => int portTime;\n\t\t\tfor(0 => int x; x < portTime; x++){\n\t\t\t\tcurrentFreq + ((destFreq - currentFreq) * x \/ portTime) => bassTone.freq;\n\t\t\t\tbassTone.freq() * 2 - 3 => octTone.freq;\n\t\t\t\tbassTone.freq() => Std.ftom => fifthNote;\n\t\t\t\tfifthNote + 7 => Std.mtof => fifthTone.freq;\n\t\t\t\t1::ms => now;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfun void oscGetMelody(){\n\twhile(true){\n\t\tom => now;\n\t\twhile(om.nextMsg()){\n\t\t\t<<<\"received melody\">>>;\n\t\t\tint notes[8];\n\t\t\tint id;\n\t\t\tif(true){\n\t\t\t\tMath.random2(270, 500) => float melTime;\n\t\t\t\tom.getFloat() => timbre;\n\t\t\t\tom.getInt() * (800 \/ melTime) $ int => lifetime;\n\t\t\t\tfor(0 => int x; x < notes.cap(); x++){\n\t\t\t\t\tom.getInt() => notes[x];\n\t\t\t\t}\n\t\t\t\tom.getInt() => id;\n\t\t\t\tspork ~ melody(notes, timbre, melTime::ms, lifetime, id);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfun void melody(int notes[], float timbre, dur notedel, int beats, int id){\n\tfor(0 => int x; x < beats; x++){\n\t\tif(true){\n\t\t\tMath.random2(0, 10)::ms => now;\n\t\t\tif(notes[x % 8] > 60){\n\t\t\t\tspork ~ makeMelody(notes[x % 8], timbre, 1 - Math.pow(x $ float \/ beats $ float, 1.2), id);\n\t\t\t}\n\t\t}\n\t\tnotedel => now;\n\t}\n}\n\nfun void makeMelody(int note, float timbre, float gain, int id){\n\txmit.startMsg( \"\/id\", \"i\" );\n\tid => xmit.addInt;\n\t84 + (note + key) % 12 => Std.mtof => s[activeMelSynth % numSynths].freq;\n\tgain * 0.03 => s[activeMelSynth % numSynths].gain;\n\t(id % 5) * 800 + 1700 => lpm[activeMelSynth % numSynths].freq;\n\t\/\/Math.sin(timbre * 7104) * 1.5 + 1 => lpm[activeMelSynth % numSynths].Q;\n\tMath.sin(timbre * 16931) => p[activeMelSynth % numSynths].pan;\n\t((Math.sin(timbre * 13063) + 1) * 80)::ms => e[activeMelSynth % numSynths].attackTime;\n\t((Math.sin(timbre * 13063) + 1.5) * 400)::ms => e[activeMelSynth % numSynths].decayTime;\n\te[activeMelSynth % numSynths].keyOn();\n\tactiveMelSynth => int capNote;\n\t1 +=> activeMelSynth;\n\te[activeMelSynth % numSynths].keyOff();\n\t3000::ms => now;\n\te[capNote % numSynths].keyOff();\n}\n\nfun void chordLfo(){\n\twhile(true){\n\t\tfor(0 => int i; i < numSynths; i++){\n\t\t\t(lfoDepth[i] * Math.sin(lfoTime \/ lfoSpeed[i])) + 800 => lp[i].freq;\n\t\t}\n\t\tlfoTime++;\n\t\t10::ms => now;\n\t}\n}\n\nfun void drumPlay(){\n\tif(drumRunning == 0){\n\t\t<<<\"drums\">>>;\n\t\t1 => drumRunning;\n\t\tMath.random2(600, 800) => int druml;\n\t\tfor(0 => int x; x < 50; x++){\n\t\t\tdruml + Math.random2(-10, 10) => druml;\n\t\t\tfor(0 => int i; i < druml; i++){\n\t\t\t\tdrum.freq(Math.exp(-0.1 * i) * 400 + (bassTone.freq() \/ 2));\n\t\t\t\tMath.sin(x $ float * Math.PI \/ 50) * 0.08 => drum.gain;\n\t\t\t\t1::ms => now;\n\t\t\t}\n\t\t}\n\t\t0 => drumRunning;\n\t}\n}\n\nfor(0 => int i; i < numSynths; i++){\n\tosc[i] => env[i] => lp[i] => oscPan[i];\n\t0.042 => osc[i].gain;\n\toscPan[i].left => lrev;\n\toscPan[i].right => rrev;\n\t0.75 - 1.5 * (i $ float \/ (numSynths - 1)) => oscPan[i].pan;\n\t<<>>;\n\t400::ms => env[i].attackTime;\n\t60::ms => env[i].decayTime;\n\t0.8 => env[i].sustainLevel;\n\t1000::ms => env[i].releaseTime;\n\t1200 => lp[i].freq;\n\t3.5 => lp[i].Q;\n\tMath.random2f(200, 500) => lfoDepth[i];\n\tMath.random2f(80, 200) => lfoSpeed[i];\n}\n\nfor(0 => int x; x < numMelSynths; x++){\n s[x] => e[x] => lpm[x] => p[x];\n p[x].left => lmelrev;\n p[x].right => rmelrev;\n 0.03 => s[x].gain;\n 3::ms => e[x].attackTime;\n 60::ms => e[x].decayTime;\n 0.2 => e[x].sustainLevel;\n 400::ms => e[x].releaseTime;\n 2 => lpm[x].Q;\n}\n\nspork ~ chordLfo();\nspork ~ oscGetChord();\nspork ~ oscGetMelody();\nspork ~ drumPlay();\nint sameNote;\nfloat synthNote;\n\n0.3 => dac.gain;\n\nwhile(true){\n\tif(Math.randomf() > 0.4){\n\t\t1 => int sameNote;\n\t\t0 => int c;\n\t\twhile(sameNote > 0 && c < 40){\n\t\t\t60 + key + chordNotes[type][root][Math.random2(0, chordNotes[type][root].cap() - 1)] => Std.mtof => synthNote;\n\t\t\t<<<\"Tried to make note: \", synthNote>>>;\n\t\t\t0 => sameNote;\n\t\t\tc++;\n\t\t\tfor(0 => int x; x < numSynths; x++){\n\t\t\t\tif(synthNote < osc[x].freq() + noteDistance && synthNote > osc[x].freq() - noteDistance){\n\t\t\t\t\tsameNote++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsynthNote + Math.random2f(-1 * detune, detune) => osc[activeSynth].freq;\n\t\tenv[activeSynth].keyOn(1);\n\t\t<<<\"Made note: \", osc[activeSynth].freq()>>>;\n\t\tactiveSynth++;\n\t\tif(activeSynth == numSynths){\n\t\t\t0 => activeSynth;\n\t\t}\n\t\tenv[activeSynth].keyOff(1);\n\t}\n\telse if(Math.randomf() > 0.94){\n\t\tspork ~ drumPlay();\n\t}\n\tMath.random2(1500, 2000)::ms => now;\n}","old_contents":"\n\nOscRecv recv2;\n6449 => recv2.port;\nrecv2.listen();\nrecv2.event( \"\/timbre\/lifetime\/n1\/n2\/n3\/n4\/n5\/n6\/n7\/n8\/id, f i i i i i i i i i i\" ) @=> OscEvent @ om;\n\/\/ key is an integer MIDI note value (e.g., C is 0, C# is 1, etc.)\n\/\/ root is an integer MIDI note value (e.g., C is 0, C# is 1, etc.)\n\/\/ type is an integer (0 = major, 1 = minor, 2=dim, 3=aug, 4=sus4, 5=dom7)\n\nOscRecv recv;\n6450 => recv.port;\nrecv.listen();\nrecv.event( \"\/key\/root\/type, i i i\" ) @=> OscEvent @ oe;\n\nOscSend xmit;\nxmit.setHost(\"localhost\", 6452);\n\n\n0 => int key;\n0 => int root;\n0 => int type;\n600 => float portamento;\n1.5 => int detune;\n4 => int numSynths;\n0 => int activeSynth;\n0 => int activeMelSynth;\n0 => int lfoTime;\n30 => int noteDistance;\n10 => int numMelSynths;\nfloat timbre;\n\"\" => string activeid;\n[ [ [0, 2, 4, 7, 12],\n\t[1, 5, 8, 13],\n\t[0, 2, 4, 9, 12, 14],\n\t[3, 7, 10, 15],\n\t[2, 4, 8, 9, 11, 16],\n\t[0, 5, 7, 9, 12, 14],\n\t[4, 6, 10, 13],\n\t[2, 7, 9, 11, 14],\n\t[0, 3, 8, 12, 15],\n\t[4, 7, 9, 13, 14, 16],\n\t[2, 5, 9, 10, 12, 14],\n\t[-1, 6, 11, 15] ],\n [ [0, 2, 3, 5, 7, 10, 12, 15],\n\t[1, 4, 8, 13],\n\t[2, 4, 5, 9, 12, 14],\n\t[3, 5, 6, 10, 15],\n\t[4, 7, 9, 11, 14, 16],\n\t[0, 5, 7, 8, 12, 14],\n\t[6, 9, 13],\n\t[2, 6, 7, 9, 10, 12, 14],\n\t[0, 3, 8, 11, 15],\n\t[4, 9, 11, 12, 14, 16],\n\t[5, 9, 10, 12, 13],\n\t[-1, 6, 9, 11, 14] ],\n [ [0],\n [1],\n [2],\n [3],\n [4],\n [5],\n [6],\n [7],\n [8],\n [9],\n [10],\n [2, 5, 11, 14] ],\n [ [0] ],\n [ [0, 2, 5, 7, 9, 12],\n\t[1, 5, 8, 13],\n\t[2, 4, 6, 9, 12, 14],\n\t[3, 7, 10, 15],\n\t[2, 4, 8, 9, 11, 16],\n\t[0, 5, 7, 9, 12, 14],\n\t[4, 6, 10, 13],\n\t[2, 7, 9, 11, 14],\n\t[0, 3, 8, 12, 15],\n\t[4, 7, 9, 13, 14, 16],\n\t[2, 5, 9, 10, 12, 14],\n\t[-1, 6, 11, 15] ],\n [ [0, 4, 7, 10, 12],\n\t[1, 5, 8, 13],\n\t[2, 4, 6, 9, 12, 14],\n\t[3, 7, 10, 15],\n\t[2, 4, 8, 9, 11, 16],\n\t[0, 5, 7, 9, 12, 14],\n\t[4, 6, 10, 13],\n\t[2, 5, 7, 11, 12, 14],\n\t[0, 3, 8, 12, 15],\n\t[4, 7, 9, 13, 14, 16],\n\t[2, 5, 9, 10, 12, 14],\n\t[-1, 6, 11, 15] ],\n [ [0, 2, 3, 5, 7, 10, 12, 15],\n\t[1, 4, 8, 13],\n\t[0, 2, 4, 5, 9, 12, 14],\n\t[3, 5, 6, 10, 15],\n\t[2, 4, 7, 9, 11, 14, 16],\n\t[0, 5, 7, 8, 12, 14],\n\t[4, 6, 9, 13],\n\t[2, 6, 7, 9, 10, 12, 14],\n\t[0, 3, 8, 11, 15],\n\t[4, 7, 9, 11, 12, 14, 16],\n\t[5, 9, 10, 12, 13],\n\t[-1, 6, 9, 11, 14] ] ] @=> int chordNotes[][][];\n\nSawOsc bassTone => NRev bassRev => LPF bassLp => dac;\n0.04 => bassTone.gain;\n400 => bassLp.freq;\n0.3 => bassRev.mix;\n3 => bassLp.Q;\n\nTriOsc fifthTone => NRev fifthRev => LPF fifthLp => dac;\n0.03 => fifthTone.gain;\n600 => fifthLp.freq;\n0.2 => fifthRev.mix;\n2 => fifthLp.Q;\n\nTriOsc octTone => NRev octRev => LPF octLp => dac;\n0.03 => octTone.gain;\n800 => octLp.freq;\n0.2 => octRev.mix;\n2 => octLp.Q;\n\nPRCRev lrev;\nLPF lmasterLP;\n0.6 => lrev.mix;\n2000 => lmasterLP.freq;\n1 => lmasterLP.Q;\nlrev => lmasterLP => dac.left;\n\nPRCRev rrev;\nLPF rmasterLP;\n0.6 => rrev.mix;\n2000 => rmasterLP.freq;\n1 => rmasterLP.Q;\nrrev => rmasterLP => dac.right;\n\nNRev lmelrev => Dyno lmeld => dac.left;\n0.3 => lmelrev.mix;\nlmeld.limit();\nlmeld.thresh(0.16);\nNRev rmelrev => Dyno rmeld => dac.right;\n0.3 => rmelrev.mix;\nrmeld.limit();\nrmeld.thresh(0.16);\n\nSinOsc drum => LPF drumf => dac;\n1000 => drumf.freq;\n0.3 => drumf.Q;\n0 => int drumRunning;\n\nSawOsc osc[numSynths];\nADSR env[numSynths];\nLPF lp[numSynths];\nPan2 oscPan[numSynths];\nfloat lfoSpeed[numSynths];\nfloat lfoDepth[numSynths];\nSqrOsc s[numMelSynths];\nADSR e[numMelSynths];\nPan2 p[numMelSynths];\nLPF lpm[numMelSynths];\nfloat fifthNote;\nint note;\nint lifetime;\n\nfun void oscGetChord(){\n\twhile(true){\n\t\toe => now;\n\t\twhile(oe.nextMsg()){\n\t\t\t<<<\"osc recieved\">>>;\n\t\t\toe.getInt() % 12 => key;\n\t\t\toe.getInt() % 12 => root;\n\t\t\toe.getInt() => type;\n\t\t\tbassTone.freq() => float currentFreq;\n\t\t\t(root + key) % 12 + 48 => Std.mtof => float destFreq;\n\t\t\tMath.max(Math.round(portamento * Math.random2f(-0.4, 1.2)), 18) $ int => int portTime;\n\t\t\tfor(0 => int x; x < portTime; x++){\n\t\t\t\tcurrentFreq + ((destFreq - currentFreq) * x \/ portTime) => bassTone.freq;\n\t\t\t\tbassTone.freq() * 2 - 3 => octTone.freq;\n\t\t\t\tbassTone.freq() => Std.ftom => fifthNote;\n\t\t\t\tfifthNote + 7 => Std.mtof => fifthTone.freq;\n\t\t\t\t1::ms => now;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfun void oscGetMelody(){\n\twhile(true){\n\t\tom => now;\n\t\twhile(om.nextMsg()){\n\t\t\t<<<\"received melody\">>>;\n\t\t\tint notes[8];\n\t\t\tint id;\n\t\t\tif(true){\n\t\t\t\tMath.random2(270, 500) => float melTime;\n\t\t\t\tom.getFloat() => timbre;\n\t\t\t\tom.getInt() * (800 \/ melTime) $ int => lifetime;\n\t\t\t\tfor(0 => int x; x < notes.cap(); x++){\n\t\t\t\t\tom.getInt() => notes[x];\n\t\t\t\t}\n\t\t\t\tom.getInt() => id;\n\t\t\t\tspork ~ melody(notes, timbre, melTime::ms, lifetime, id);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfun void melody(int notes[], float timbre, dur notedel, int beats, int id){\n\tfor(0 => int x; x < beats; x++){\n\t\tif(true){\n\t\t\tMath.random2(0, 10)::ms => now;\n\t\t\tif(notes[x % 8] > 60){\n\t\t\t\tspork ~ makeMelody(notes[x % 8], timbre, 1 - Math.pow(x $ float \/ beats $ float, 1.2), id);\n\t\t\t}\n\t\t}\n\t\tnotedel => now;\n\t}\n}\n\nfun void makeMelody(int note, float timbre, float gain, int id){\n\txmit.startMsg( \"\/id\", \"i\" );\n\tid => xmit.addInt;\n\t84 + (note + key) % 12 => Std.mtof => s[activeMelSynth % numSynths].freq;\n\tgain * 0.03 => s[activeMelSynth % numSynths].gain;\n\t(id % 5) * 800 + 1700 => lpm[activeMelSynth % numSynths].freq;\n\t\/\/Math.sin(timbre * 7104) * 1.5 + 1 => lpm[activeMelSynth % numSynths].Q;\n\tMath.sin(timbre * 16931) => p[activeMelSynth % numSynths].pan;\n\t((Math.sin(timbre * 13063) + 1) * 80)::ms => e[activeMelSynth % numSynths].attackTime;\n\t((Math.sin(timbre * 13063) + 1.5) * 400)::ms => e[activeMelSynth % numSynths].decayTime;\n\te[activeMelSynth % numSynths].keyOn();\n\tactiveMelSynth => int capNote;\n\t1 +=> activeMelSynth;\n\te[activeMelSynth % numSynths].keyOff();\n\t3000::ms => now;\n\te[capNote % numSynths].keyOff();\n}\n\nfun void chordLfo(){\n\twhile(true){\n\t\tfor(0 => int i; i < numSynths; i++){\n\t\t\t(lfoDepth[i] * Math.sin(lfoTime \/ lfoSpeed[i])) + 800 => lp[i].freq;\n\t\t}\n\t\tlfoTime++;\n\t\t10::ms => now;\n\t}\n}\n\nfun void drumPlay(){\n\tif(drumRunning == 0){\n\t\t<<<\"drums\">>>;\n\t\t1 => drumRunning;\n\t\tMath.random2(600, 800) => int druml;\n\t\tfor(0 => int x; x < 50; x++){\n\t\t\tdruml + Math.random2(-10, 10) => druml;\n\t\t\tfor(0 => int i; i < druml; i++){\n\t\t\t\tdrum.freq(Math.exp(-0.1 * i) * 400 + (bassTone.freq() \/ 2));\n\t\t\t\tMath.sin(x $ float * Math.PI \/ 50) * 0.08 => drum.gain;\n\t\t\t\t1::ms => now;\n\t\t\t}\n\t\t}\n\t\t0 => drumRunning;\n\t}\n}\n\nfor(0 => int i; i < numSynths; i++){\n\tosc[i] => env[i] => lp[i] => oscPan[i];\n\t0.042 => osc[i].gain;\n\toscPan[i].left => lrev;\n\toscPan[i].right => rrev;\n\t0.75 - 1.5 * (i $ float \/ (numSynths - 1)) => oscPan[i].pan;\n\t<<>>;\n\t400::ms => env[i].attackTime;\n\t60::ms => env[i].decayTime;\n\t0.8 => env[i].sustainLevel;\n\t1000::ms => env[i].releaseTime;\n\t1200 => lp[i].freq;\n\t3.5 => lp[i].Q;\n\tMath.random2f(200, 500) => lfoDepth[i];\n\tMath.random2f(80, 200) => lfoSpeed[i];\n}\n\nfor(0 => int x; x < numMelSynths; x++){\n s[x] => e[x] => lpm[x] => p[x];\n p[x].left => lmelrev;\n p[x].right => rmelrev;\n 0.03 => s[x].gain;\n 3::ms => e[x].attackTime;\n 60::ms => e[x].decayTime;\n 0.2 => e[x].sustainLevel;\n 400::ms => e[x].releaseTime;\n 2 => lpm[x].Q;\n}\n\nspork ~ chordLfo();\nspork ~ oscGetChord();\nspork ~ oscGetMelody();\nspork ~ drumPlay();\nint sameNote;\nfloat synthNote;\n\n0.3 => dac.gain;\n\nwhile(true){\n\tif(Math.randomf() > 0.4){\n\t\t1 => int sameNote;\n\t\t0 => int c;\n\t\twhile(sameNote > 0 && c < 40){\n\t\t\t60 + key + chordNotes[type][root][Math.random2(0, chordNotes[type][root].cap() - 1)] => Std.mtof => synthNote;\n\t\t\t<<<\"Tried to make note: \", synthNote>>>;\n\t\t\t0 => sameNote;\n\t\t\tc++;\n\t\t\tfor(0 => int x; x < numSynths; x++){\n\t\t\t\tif(synthNote < osc[x].freq() + noteDistance && synthNote > osc[x].freq() - noteDistance){\n\t\t\t\t\tsameNote++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsynthNote + Math.random2f(-1 * detune, detune) => osc[activeSynth].freq;\n\t\tenv[activeSynth].keyOn(1);\n\t\t<<<\"Made note: \", osc[activeSynth].freq()>>>;\n\t\tactiveSynth++;\n\t\tif(activeSynth == numSynths){\n\t\t\t0 => activeSynth;\n\t\t}\n\t\tenv[activeSynth].keyOff(1);\n\t}\n\telse if(Math.randomf() > 0.94){\n\t\tspork ~ drumPlay();\n\t}\n\tMath.random2(1500, 2000)::ms => now;\n}","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"378004f948881c56655fb8d8ebd27b5e1a3183cb","subject":"main comment","message":"main comment\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"main.ck","new_file":"main.ck","new_contents":"\/**\n * This is an example main.ck file. It way produced\n * as a main file to play my concerts, so everything\n * is working and tested. The problem with it and\n * the rest of classes is that ChucK supports\n * Mac OSX *much* better than other platforms\n * Linux is the least supported. This is why\n * SndBuf was used instead of LiSa. :shrug:\n * Some bugs and strange \"shortcuts\" can be\n * the ffect of that situation. At the moment\n * the main problem with Beta Vulgaris is:\n *\n * 1. Lack of perlin noise in ChucK. I use simple\n * applet written in Processing and sending\n * perlin noise control signal via OSC\n *\n * 2. MIDI can't handle two MIDI events at one time\n * It's horrible, so in future MIDI-to-OSC\n * interface will be produced in Processing or sth.\n *\n * Have fun!!\n *\/\n\n\/\/ midi communication\nMidiIn midi_in;\nMidiMsg midi_msg;\n\/\/ midi event\nMidiEvent midi_event;\n\n\/\/ keyboard communication\nKBHit kb;\n\/\/ keyboard event\nKeyEvent e;\n\n\/\/ osc receiver\n\/\/ all osc events in this code come from Processing applet\n\/\/ that produces 1Dimensional perlin noise\n\/\/ Maybe in future it will provide an interface to\n\/\/ malfunctioning MIDI control\nOscRecv osc_receiver;\n5601 => osc_receiver.port;\nosc_receiver.listen();\n\n\nLooper looper[Globals.NUM_OF_TRACKS];\nCutter cutter[Globals.NUM_OF_TRACKS];\nPanner panner[Globals.NUM_OF_TRACKS];\nThreshold threshold[Globals.NUM_OF_TRACKS];\nStammer stammer[Globals.NUM_OF_TRACKS];\nGainer gainer[Globals.NUM_OF_TRACKS];\nGain master[Globals.NUM_OF_TRACKS];\n\nGain left, right;\n\nfor(0 => int i; i < Globals.NUM_OF_TRACKS; ++i) {\n looper[i].play();\n looper[i] => Loader.load_sound_files;\n\n cutter[i].play();\n osc_receiver.event(\"\/f\" + (i+1) + \",f\") => panner[i].osc_event;\n panner[i].play();\n threshold[i].play();\n stammer[i].play();\n osc_receiver.event(\"\/f\" + (i+21) + \",f\") => gainer[i].osc_event;\n gainer[i].play();\n}\n\n\n{ \/\/ track 0\n \/\/ this code has to be reimplemented as a separate class!!\n looper[0].connect(stammer[0]);\n stammer[0].connect(master[0]);\n master[0] => dac;\n}\n{ \/\/ track 1\n looper[1].connect(master[1]);\n master[1] => dac;\n}\n{ \/\/ track 2\n looper[2].connect(master[2]);\n master[2] => dac;\n}\n{ \/\/ track 3\n \/\/ this code has to be reimplemented as a separate class!!\n looper[3].connect(cutter[3]);\n cutter[3].connect(threshold[3]);\n threshold[3].connect(gainer[3]);\n gainer[3].connect(master[3]);\n master[3] => panner[3].input();\n panner[3].connect(dac);\n}\n{ \/\/ track 4\n \/\/ this code has to be reimplemented as a separate class!!\n looper[4].connect(cutter[4]);\n cutter[4].connect(threshold[4]);\n threshold[4].connect(gainer[4]);\n gainer[4].connect(master[4]);\n master[4] => panner[4].input();\n panner[4].connect(dac);\n}\n{ \/\/ track 5\n \/\/ this code has to be reimplemented as a separate class!!\n Delay d1, d2, d3;\n\n 15005::ms => d1.max => d2.max => d3.max;\n 5::second => d1.delay;\n 10::second => d2.delay;\n 15::second => d3.delay;\n\n Cutter c1, c2, c3;\n 4.0 => c1.set_freq;\n 8.0 => c1.set_freq;\n 15.0 => c1.set_freq;\n c1.play();\n c2.play();\n c3.play();\n\n Gainer g1, g2, g3;\n osc_receiver.event(\"\/f\" + 11 + \",f\") => g1.osc_event;\n osc_receiver.event(\"\/f\" + 12 + \",f\") => g2.osc_event;\n osc_receiver.event(\"\/f\" + 13 + \",f\") => g3.osc_event;\n g1.play();\n g2.play();\n g3.play();\n\n Panner p1, p2, p3;\n osc_receiver.event(\"\/f\" + 14 + \",f\") => p1.osc_event;\n osc_receiver.event(\"\/f\" + 15 + \",f\") => p2.osc_event;\n osc_receiver.event(\"\/f\" + 16 + \",f\") => p3.osc_event;\n p1.play();\n p2.play();\n p3.play();\n\n\n looper[5].connect(cutter[5]);\n looper[5]._output => d1;\n d1 => c1.input();\n looper[5]._output => d2;\n d2 => c2.input();\n looper[5]._output => d3;\n d3 => c3.input();\n\n cutter[5].connect(gainer[5]);\n c1.connect(g1);\n c2.connect(g2);\n c3.connect(g3);\n\n gainer[5].connect(panner[5]);\n g1.connect(p1);\n g2.connect(p2);\n g3.connect(p3);\n\n \/\/ is it a bug that Pan2 goes mono\n \/\/ when connected to Gain?\n panner[5].connect_left(left);\n panner[5].connect_right(right);\n p1.connect_left(left);\n p1.connect_right(right);\n p2.connect_left(left);\n p2.connect_right(right);\n p3.connect_left(left);\n p3.connect_right(right);\n\n left => dac.left;\n right => dac.right;\n}\n\n\n\/\/ midi listener\nspork ~ midi_listener();\nspork ~ midi_handler(midi_event);\n\n\n\/\/ main time loop\nwhile(true) {\n 1::samp => now;\n}\n\n\n\n\/\/ these function are here, because they need\n\/\/ an acces to Beets and UGens on tracks\n\/\/ to be completely re-implemented\n\/\/ with event handlers inside classes\n\/\/ just like with OSC messages\n\/\/ possible solution is to write external MIDI-to-OSC\n\/\/ interface as ChucK handles MIDI really bad\nfun void midi_handler(MidiEvent e) {\n float first_track_gain_reminder;\n int first_track_mute;\n\n float last_track_gain_reminder;\n int last_track_mute;\n\n while(true) {\n show_state();\n\n \/\/ wait for the midi event to come\n e => now;\n\n (e.cc_number \/ 10) - 1 => int track_num;\n e.cc_number % 10 => int control_num;\n\n\n \/\/ first four controls have the same function\n \/\/ for all the tracs, so are handled by control_num\n\n \/\/ V O L U M E\n if(control_num == 1) {\n if(track_num == 0 && first_track_mute == 1) {\n Utils.map_midi(e.cc_value) => first_track_gain_reminder;\n continue;\n }\n if(track_num == 5) {\n if(last_track_mute == 1) {\n Utils.map_midi(e.cc_value) => last_track_gain_reminder;\n }\n else {\n Utils.map_midi(e.cc_value) => left.gain;\n Utils.map_midi(e.cc_value) => right.gain;\n }\n continue;\n }\n\n Utils.map_midi(e.cc_value) => master[track_num].gain;\n continue;\n }\n \/\/ M U T E\n if(control_num == 2) {\n if(track_num == 0) {\n if(e.cc_value == 127) {\n master[track_num].gain() => first_track_gain_reminder;\n 0.0 => master[track_num].gain;\n 1 => first_track_mute;\n }\n else {\n first_track_gain_reminder => master[track_num].gain;\n 0 => first_track_mute;\n }\n continue;\n }\n if(track_num == 5) {\n if(e.cc_value == 127) {\n left.gain() => last_track_gain_reminder;\n 0.0 => left.gain;\n 0.0 => right.gain;\n\n 1 => last_track_mute;\n }\n else {\n last_track_gain_reminder => left.gain;\n last_track_gain_reminder => right.gain;\n\n 0 => last_track_mute;\n }\n continue;\n }\n\n Utils.map_midi(e.cc_value) $ int => int mute;\n if(mute == 0) {\n looper[track_num].play();\n }\n else {\n looper[track_num].stop();\n }\n continue;\n }\n if(control_num == 3) {\n \/\/ nothing going on there\n continue;\n }\n \/\/ F I L E S E L E C T I O N\n if(control_num == 4) {\n Utils.map_midi(e.cc_value, 0.0, looper[track_num].length() - 1.01) => float index;\n index $ int => looper[track_num].current_file;\n continue;\n }\n \/\/ P L A Y B A C K R A T E\n if(control_num == 5) {\n Utils.map_midi(e.cc_value, -2.0, 2.0) => looper[track_num].set_speed;\n continue;\n }\n\n \/\/ the rest of controls have different functions\n \/\/ for each track, so they are handled by track_num\n \/\/ T R A C K 1\n \/\/ T R A C K 2\n \/\/ T R A C K 3\n if(track_num == 0 && control_num == 6) {\n Utils.map_midi(e.cc_value, 2.0, 9.0) => stammer[track_num].set_freq;\n continue;\n }\n if(track_num == 3 || track_num == 4) {\n if(control_num == 7) {\n Utils.map_midi(e.cc_value, 0.0, 1.0) => threshold[track_num].set_threshold;\n continue;\n }\n if(control_num == 8) {\n Utils.map_midi(e.cc_value, 2.0, 25.0) => cutter[track_num].set_freq;\n continue;\n }\n }\n }\n}\n\n\n\nfun void midi_listener() {\n if(!midi_in.open(1)) {\n <<< \">>>\", \"MIDI can't be open\" >>>;\n me.exit();\n }\n\n while(true) {\n midi_in => now;\n\n while(midi_in.recv(midi_msg)) {\n \/\/ get cc number\n midi_msg.data2 => midi_event.cc_number;\n \/\/ get cc value\n midi_msg.data3 => midi_event.cc_value;\n\n \/\/ uncomment it to see, what is actually going on with MIDI\n \/\/ <<< midi_event.cc_number, \"::\", midi_event.cc_value >>>;\n\n \/\/ broadcast new data\n midi_event.broadcast();\n }\n }\n}\n\nfun void show_state() {\n Utils.clear_screen();\n\n for(0 => int i; i < Globals.NUM_OF_TRACKS; ++i) {\n <<< \"Track\", (i+1) >>>;\n <<< looper[i].show_current_state() >>>;\n <<< \"-------------\", \"-----------\" >>>;\n }\n}\n","old_contents":"\/**\n * This is an example main.ck file. It way produced\n * as a main file to play my concerts, so everything\n * is working and tested. The problem with it and\n * the rest of classes is that ChucK supports \n * Mac OSX *much* better than other platforms\n * Linux is the least supported. This is why \n * SndBuf was used instead of LiSa. \n * Some bugs and strange \"shortcuts\" can be\n * the ffect of that situation. At the moment\n * the main problem with Beta Vulgaris is:\n *\n * 1. Lack of perlin noise in ChucK. I use simple\n * applet written in Processing and sending\n * perlin noise control signal via OSC\n *\n * 2. MIDI can't handle two MIDI events at one time\n * It's horrible, so in future MIDI-to-OSC\n * interface will be produced in Processing or sth. \n *\n * Have fun!!\n *\/\n\n\/\/ midi communication\nMidiIn midi_in;\nMidiMsg midi_msg;\n\/\/ midi event\nMidiEvent midi_event;\n\n\/\/ keyboard communication\nKBHit kb;\n\/\/ keyboard event\nKeyEvent e;\n\n\/\/ osc receiver\n\/\/ all osc events in this code come from Processing applet\n\/\/ that produces 1Dimensional perlin noise\n\/\/ Maybe in future it will provide an interface to\n\/\/ malfunctioning MIDI control\nOscRecv osc_receiver;\n5601 => osc_receiver.port;\nosc_receiver.listen();\n\n\nLooper looper[Globals.NUM_OF_TRACKS];\nCutter cutter[Globals.NUM_OF_TRACKS];\nPanner panner[Globals.NUM_OF_TRACKS];\nThreshold threshold[Globals.NUM_OF_TRACKS];\nStammer stammer[Globals.NUM_OF_TRACKS];\nGainer gainer[Globals.NUM_OF_TRACKS];\nGain master[Globals.NUM_OF_TRACKS];\n\nGain left, right;\n\nfor(0 => int i; i < Globals.NUM_OF_TRACKS; ++i) {\n looper[i].play();\n looper[i] => Loader.load_sound_files;\n \n cutter[i].play();\n osc_receiver.event(\"\/f\" + (i+1) + \",f\") => panner[i].osc_event;\n panner[i].play();\n threshold[i].play();\n stammer[i].play();\n osc_receiver.event(\"\/f\" + (i+21) + \",f\") => gainer[i].osc_event;\n gainer[i].play();\n}\n\n\n{ \/\/ track 0\n \/\/ this code has to be reimplemented as a separate class!! \n looper[0].connect(stammer[0]);\n stammer[0].connect(master[0]);\n master[0] => dac;\n}\n{ \/\/ track 1 \n looper[1].connect(master[1]);\n master[1] => dac; \n}\n{ \/\/ track 2\n looper[2].connect(master[2]);\n master[2] => dac; \n}\n{ \/\/ track 3\n \/\/ this code has to be reimplemented as a separate class!! \n looper[3].connect(cutter[3]);\n cutter[3].connect(threshold[3]);\n threshold[3].connect(gainer[3]);\n gainer[3].connect(master[3]);\n master[3] => panner[3].input();\n panner[3].connect(dac);\n}\n{ \/\/ track 4\n \/\/ this code has to be reimplemented as a separate class!! \n looper[4].connect(cutter[4]);\n cutter[4].connect(threshold[4]);\n threshold[4].connect(gainer[4]);\n gainer[4].connect(master[4]);\n master[4] => panner[4].input();\n panner[4].connect(dac);\n}\n{ \/\/ track 5\n \/\/ this code has to be reimplemented as a separate class!!\n Delay d1, d2, d3;\n\n 15005::ms => d1.max => d2.max => d3.max;\n 5::second => d1.delay;\n 10::second => d2.delay;\n 15::second => d3.delay;\n\n Cutter c1, c2, c3;\n 4.0 => c1.set_freq;\n 8.0 => c1.set_freq;\n 15.0 => c1.set_freq; \n c1.play();\n c2.play();\n c3.play(); \n\n Gainer g1, g2, g3;\n osc_receiver.event(\"\/f\" + 11 + \",f\") => g1.osc_event;\n osc_receiver.event(\"\/f\" + 12 + \",f\") => g2.osc_event;\n osc_receiver.event(\"\/f\" + 13 + \",f\") => g3.osc_event; \n g1.play();\n g2.play();\n g3.play(); \n \n Panner p1, p2, p3;\n osc_receiver.event(\"\/f\" + 14 + \",f\") => p1.osc_event;\n osc_receiver.event(\"\/f\" + 15 + \",f\") => p2.osc_event;\n osc_receiver.event(\"\/f\" + 16 + \",f\") => p3.osc_event; \n p1.play();\n p2.play();\n p3.play(); \n\n \n looper[5].connect(cutter[5]);\n looper[5]._output => d1;\n d1 => c1.input();\n looper[5]._output => d2;\n d2 => c2.input(); \n looper[5]._output => d3;\n d3 => c3.input();\n\n cutter[5].connect(gainer[5]);\n c1.connect(g1);\n c2.connect(g2);\n c3.connect(g3);\n \n gainer[5].connect(panner[5]);\n g1.connect(p1);\n g2.connect(p2);\n g3.connect(p3);\n\n \/\/ is it a bug that Pan2 goes mono\n \/\/ when connected to Gain?\n panner[5].connect_left(left);\n panner[5].connect_right(right);\n p1.connect_left(left);\n p1.connect_right(right);\n p2.connect_left(left);\n p2.connect_right(right);\n p3.connect_left(left);\n p3.connect_right(right);\n\n left => dac.left;\n right => dac.right;\n}\n\n\n\/\/ midi listener\nspork ~ midi_listener();\nspork ~ midi_handler(midi_event);\n\n\n\/\/ main time loop\nwhile(true) { \n 1::samp => now;\n}\n\n\n\n\/\/ these function are here, because they need\n\/\/ an acces to Beets and UGens on tracks\n\/\/ to be completely re-implemented\n\/\/ with event handlers inside classes\n\/\/ just like with OSC messages\n\/\/ possible solution is to write external MIDI-to-OSC\n\/\/ interface as ChucK handles MIDI really bad\nfun void midi_handler(MidiEvent e) {\n float first_track_gain_reminder;\n int first_track_mute;\n\n float last_track_gain_reminder;\n int last_track_mute;\n \n while(true) {\n show_state();\n\n \/\/ wait for the midi event to come\n e => now;\n\n (e.cc_number \/ 10) - 1 => int track_num;\n e.cc_number % 10 => int control_num;\n\n \n \/\/ first four controls have the same function\n \/\/ for all the tracs, so are handled by control_num\n \n \/\/ V O L U M E\n if(control_num == 1) {\n if(track_num == 0 && first_track_mute == 1) {\n Utils.map_midi(e.cc_value) => first_track_gain_reminder;\n continue;\n }\n if(track_num == 5) {\n if(last_track_mute == 1) {\n Utils.map_midi(e.cc_value) => last_track_gain_reminder;\n }\n else {\n Utils.map_midi(e.cc_value) => left.gain;\n Utils.map_midi(e.cc_value) => right.gain;\n }\n continue;\n }\n\n Utils.map_midi(e.cc_value) => master[track_num].gain;\n continue;\n }\n \/\/ M U T E\n if(control_num == 2) {\n if(track_num == 0) {\n if(e.cc_value == 127) {\n master[track_num].gain() => first_track_gain_reminder;\n 0.0 => master[track_num].gain;\n 1 => first_track_mute;\n }\n else {\n first_track_gain_reminder => master[track_num].gain;\n 0 => first_track_mute;\n }\n continue;\n }\n if(track_num == 5) {\n if(e.cc_value == 127) {\n left.gain() => last_track_gain_reminder;\n 0.0 => left.gain;\n 0.0 => right.gain;\n \n 1 => last_track_mute;\n }\n else {\n last_track_gain_reminder => left.gain;\n last_track_gain_reminder => right.gain;\n \n 0 => last_track_mute;\n }\n continue;\n }\n\n Utils.map_midi(e.cc_value) $ int => int mute;\n if(mute == 0) {\n looper[track_num].play();\n }\n else {\n looper[track_num].stop();\n }\n continue;\n }\n if(control_num == 3) {\n \/\/ nothing going on there\n continue;\n }\n \/\/ F I L E S E L E C T I O N\n if(control_num == 4) {\n Utils.map_midi(e.cc_value, 0.0, looper[track_num].length() - 1.01) => float index;\n index $ int => looper[track_num].current_file;\n continue;\n }\n \/\/ P L A Y B A C K R A T E \n if(control_num == 5) {\n Utils.map_midi(e.cc_value, -2.0, 2.0) => looper[track_num].set_speed;\n continue;\n }\n \n \/\/ the rest of controls have different functions\n \/\/ for each track, so they are handled by track_num\n \/\/ T R A C K 1\n \/\/ T R A C K 2\n \/\/ T R A C K 3 \n if(track_num == 0 && control_num == 6) {\n Utils.map_midi(e.cc_value, 2.0, 9.0) => stammer[track_num].set_freq;\n continue;\n }\n if(track_num == 3 || track_num == 4) {\n if(control_num == 7) {\n Utils.map_midi(e.cc_value, 0.0, 1.0) => threshold[track_num].set_threshold;\n continue;\n }\n if(control_num == 8) {\n Utils.map_midi(e.cc_value, 2.0, 25.0) => cutter[track_num].set_freq;\n continue;\n } \n }\n }\n}\n\n\n\nfun void midi_listener() { \n if(!midi_in.open(1)) {\n <<< \">>>\", \"MIDI can't be open\" >>>;\n me.exit();\n }\n\n while(true) {\n midi_in => now;\n\n while(midi_in.recv(midi_msg)) {\n \/\/ get cc number\n midi_msg.data2 => midi_event.cc_number;\n \/\/ get cc value\n midi_msg.data3 => midi_event.cc_value;\n\n \/\/ uncomment it to see, what is actually going on with MIDI\n \/\/ <<< midi_event.cc_number, \"::\", midi_event.cc_value >>>; \n\n \/\/ broadcast new data\n midi_event.broadcast();\n }\n }\n} \n\nfun void show_state() {\n Utils.clear_screen();\n \n for(0 => int i; i < Globals.NUM_OF_TRACKS; ++i) {\n <<< \"Track\", (i+1) >>>;\n <<< looper[i].show_current_state() >>>;\n <<< \"-------------\", \"-----------\" >>>;\n }\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"ChucK"} {"commit":"1b9788713af769283d2240d7fa3a3b9aaea766ff","subject":"no more changes to windchime","message":"no more changes to windchime\n\nits ok.\n","repos":"zeffii\/ChucKScripts","old_file":"patches\/melodic\/WindChime.ck","new_file":"patches\/melodic\/WindChime.ck","new_contents":"\/\/WindChime.ck\n\npublic class WindChime {\n\n Mix2 mout;\n NRev rvb => mout;\n rvb.mix(0.22);\n mout.gain(0.3);\n dur a;\n dur d;\n dur s;\n float s_level;\n dur r;\n float midint;\n 0.02 => float chime_vol; \/\/ default\n\n rvb => DelayA td => rvb;\n td.delay(70::ms);\n td.max(70::ms);\n td.gain(0.33);\n\n fun void set_chime_vol(float chime_vol){\n chime_vol => this.chime_vol;\n }\n\n fun void set_adsr(dur a, dur d, dur s, float s_level, dur r){\n a => this.a;\n d => this.d;\n s => this.s;\n s_level => this.s_level;\n r => this.r;\n }\n\n fun void s_play_note(){\n SinOsc s => ADSR env => rvb;\n SinOsc s2 => env;\n SinOsc s3 => env;\n SinOsc s0 => env;\n SinOsc m => s;\n\n env => Pan2 p;\n Math.random2f( 0.8, -0.8 ) => p.pan;\n NRev rvs[2];\n\n p.left => rvs[0] => mout.left;\n p.right => rvs[1] => mout.right;\n for(0 => int i; i Std.mtof => float gfreq => s.freq;\n s2.freq((gfreq*2) + 0.012);\n s2.gain(chime_vol*0.8);\n s3.freq(gfreq*3);\n s3.gain(chime_vol*.22);\n s0.freq(gfreq*4\/(midint\/17.65));\n s0.gain(chime_vol*.052);\n m.freq(2 * gfreq);\n m.gain(3000);\n\n \/\/ Envelope config\n env.set( a, d, s_level, r );\n env.keyOn(); \n (this.a + this.d + this.s) => now;\n env.keyOff(); \n this.r => now;\n }\n\n fun void play_note(float midint){\n midint => this.midint;\n spork ~ s_play_note();\n }\n\n \/\/ this sets a defult, incase i forget to\n set_adsr( 2::ms, 151::ms, 121::ms, .890, 35::ms ); \/\/a, d, s, r\n\n}\n\nWindChime wc;\nADSR sound_sculpt[2];\nwc.mout.left => sound_sculpt[0] => dac.left;\nwc.mout.right => sound_sculpt[1] => dac.right;\nsound_sculpt[0].set( 0::ms, 0::ms, 1.0, 3235::ms ); \/\/a, d, s, r\nsound_sculpt[1].set( 0::ms, 0::ms, 1.0, 3235::ms ); \/\/a, d, s, r\nwc.set_chime_vol(0.28);\nsound_sculpt[0].keyOn();\nsound_sculpt[1].keyOn();\n120.0 => float start_note;\nfor(0 => int i; i<28; i++){\n wc.play_note(start_note-(i*0.6));\n Math.random2f(0.12, 0.112)::second =>now;\n}\nsound_sculpt[0].keyOff();\nsound_sculpt[1].keyOff();\n\/\/ prevent clicks\n7::second => now;\n","old_contents":"\/\/WindChime.ck\n\npublic class WindChime {\n\n Mix2 mout;\n NRev rvb => mout;\n rvb.mix(0.22);\n mout.gain(0.3);\n dur a;\n dur d;\n dur s;\n float s_level;\n dur r;\n float midint;\n 0.02 => float chime_vol; \/\/ default\n\n fun void set_chime_vol(float chime_vol){\n chime_vol => this.chime_vol;\n }\n\n fun void set_adsr(dur a, dur d, dur s, float s_level, dur r){\n a => this.a;\n d => this.d;\n s => this.s;\n s_level => this.s_level;\n r => this.r;\n }\n\n fun void s_play_note(){\n SinOsc s => ADSR env => rvb;\n SinOsc s2 => env;\n SinOsc m => s;\n\n env => Pan2 p;\n Math.random2f( 0.8, -0.8 ) => p.pan;\n NRev rvs[2];\n\n p.left => rvs[0] => mout.left;\n p.right => rvs[1] => mout.right;\n for(0 => int i; i Std.mtof => float gfreq => s.freq;\n s2.freq(gfreq + 0.012);\n s2.gain(chime_vol);\n m.freq(2 * gfreq);\n m.gain(3000);\n\n \/\/ Envelope config\n env.set( a, d, s_level, r );\n env.keyOn(); \n (this.a + this.d + this.s) => now;\n env.keyOff(); \n this.r => now;\n }\n\n fun void play_note(float midint){\n midint => this.midint;\n spork ~ s_play_note();\n }\n\n \/\/ this sets a defult, incase i forget to\n set_adsr( 2::ms, 151::ms, 121::ms, .890, 35::ms ); \/\/a, d, s, r\n\n}\n\nWindChime wc;\nwc.mout => dac;\nwc.set_chime_vol(0.18);\n\n120.0 => float start_note;\nfor(0 => int i; i<25; i++){\n wc.play_note(start_note-(i*0.6));\n (0.12 )::second =>now;\n}\n\n\/\/ prevent clicks\n2::second => now;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"6de3afe958ae14e77128fabc116ab443b26002e6","subject":"Delete dBFStoGain.ck","message":"Delete dBFStoGain.ck\n\nmoved to \/utility_functions\/","repos":"zeffii\/ChucKScripts","old_file":"dBFStoGain.ck","new_file":"dBFStoGain.ck","new_contents":"","old_contents":"\/* Allows inputting a dBFS value like a normal (sound engineer)\nperson (e.g. -6dB for a \"tame\" peak value), and getting a\nChucK \"gain\" number out (e.g. for -6dB, 0.501187).\nThe results seem to indicate that ChucK's gain, calculated\nusing the 'Std.dbtorms()' method, conforms to amplitude\n(as a ratio) as shown in the chart at the top of\nhttp:\/\/en.wikipedia.org\/wiki\/Decibel.\n\nI'd call it verified:\ndBFStoGain( x ) = y\n +3 = ~1.4\n 0 = 1 \/\/ Unity gain\n -6 = ~0.5\n-12 = ~0.25\n*\/\n\n\/\/ Not exactly rocket science >_<\nfun float dBFStoGain(float dBFS){ \n return Std.dbtorms( dBFS + 100 );\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"d61ee08f382e85afd95dedb904c04b9d799b5574","subject":"updated osc receive sample","message":"updated osc receive sample\n","repos":"jordanorelli\/wii-chuck-synth","old_file":"osc_recv.ck","new_file":"osc_recv.ck","new_contents":"OscRecv recv;\n6449 => recv.port;\nrecv.listen();\n\nfun void printOscInt(string oscPath, string leader)\n{\n recv.event(oscPath) @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n chout <= leader <= e.getInt() <= IO.newline();\n }\n }\n}\n\nfun void printOscFloat(string oscPath, string leader)\n{\n recv.event(oscPath) @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n chout <= leader <= e.getFloat() <= IO.newline();\n }\n }\n}\n\nfun void pitch()\n{\n printOscFloat(\"\/wii\/1\/accel\/pry\/0,f\", \"\");\n}\n\nfun void roll()\n{\n printOscFloat(\"\/wii\/1\/accel\/pry\/1,f\", \"\\t\");\n}\n\nfun void yaw()\n{\n printOscFloat(\"\/wii\/1\/accel\/pry\/2,f\", \"\\t\\t\");\n}\n\nfun void accel()\n{\n printOscFloat(\"\/wii\/1\/accel\/pry\/3,f\", \"\\t\\t\\t\");\n}\n\nfun void A()\n{\n printOscInt(\"\/wii\/1\/button\/A,i\", \"\\t\\t\\t\\t\\t\");\n}\n\nfun void B()\n{\n printOscInt(\"\/wii\/1\/button\/B,i\", \"\\t\\t\\t\\t\\t\\t\");\n}\n\nspork ~ pitch();\nspork ~ roll();\nspork ~ yaw();\nspork ~ accel();\nspork ~ A();\nspork ~ B();\n\nwhile(true)\n{\n 1::second => now;\n}\n","old_contents":"OscRev recv;\n6449 => recv.port;\nrecv.listen();\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"6212813ba5078e9ba5bb3c7a2ca15281790a4099","subject":"refactoring, hi ho","message":"refactoring, hi ho\n","repos":"jordanorelli\/wii-chuck-synth","old_file":"resin_run.ck","new_file":"resin_run.ck","new_contents":"OscRecv wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float rawGain;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 82.4068867, 12.0) @=> oscBank;\n\n if(prompt) {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n Launchpad.Launchpad(lpChannel) @=> lp;\n } else {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone) {\n return;\n } else if(toneChoice == 0) {\n oscBank.setPatch(\"SinOsc\");\n } else if(toneChoice == 1) {\n oscBank.setPatch(\"SqrOsc\");\n } else if(toneChoice == 2) {\n oscBank.setPatch(\"SawOsc\");\n } else if(toneChoice == 3) {\n oscBank.setPatch(\"TriOsc\");\n } else {\n return;\n }\n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void setSostenuto(int enabled) {\n enabled => sostenuto;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] && enabled => sostenutoStatus[x][y];\n if(!enabled && !lp.keyDown[x][y]) {\n lp.setGridLight(x, y, 0);\n }\n }\n }\n}\n\nfun void sustainOn()\n{\n true => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sustainStatus[i][j];\n }\n }\n }\n}\n\nfun void sustainOff()\n{\n false => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sustainStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n rawGain => targetGain;\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\nfun void sustainListener()\n{\n wm.event(\"\/wii\/1\/button\/B,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sustainOff();\n }\n else\n {\n sustainOn();\n }\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,i\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSostenuto(e.getInt() != 0);\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n Math.max(0.0, e.getFloat() - 0.22) => rawGain;\n chout <= rawGain <= IO.newline();\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n \/\/ 8000 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true)\n {\n 1::second => now;\n }\n}\n\nsetup();\n\nwhile(true)\n{\n 100::ms => now;\n}\n","old_contents":"OscRecv wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float rawGain;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.red => int keyOnColor;\nLaunchpadColor.lightRed => int keySustainColor;\nLaunchpadColor.lightRed => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\/\/ ToneCalc.grid(8, 8, 1, 5, 82.4068867, 12.0) @=> float toneMap[][];\n\/\/ ToneCalc.grid(8, 8, 1, 5, 55.0, 12.0) @=> float toneMap[][];\n\nfun void setup()\n{\n \/\/ OscBank.OscBank(8, 8, 1, 5, 55.0, 12.0) @=> oscBank;\n OscBank.OscBank(8, 8, 1, 5, 82.4068867, 12.0) @=> oscBank;\n\n if(prompt)\n {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n\n Launchpad.Launchpad(lpChannel) @=> lp;\n }\n else\n {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone)\n {\n return;\n }\n\n if(toneChoice == 0)\n {\n oscBank.setPatch(\"SinOsc\");\n }\n else if(toneChoice == 1)\n {\n oscBank.setPatch(\"SqrOsc\");\n }\n else if(toneChoice == 2)\n {\n oscBank.setPatch(\"SawOsc\");\n }\n else if(toneChoice == 3)\n {\n oscBank.setPatch(\"TriOsc\");\n }\n else\n {\n return;\n }\n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void sostenutoOn()\n{\n true => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sostenutoStatus[i][j];\n }\n }\n }\n}\n\nfun void sostenutoOff()\n{\n false => sostenuto;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sostenutoStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void sustainOn()\n{\n true => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n if(lp.keyDown[i][j])\n {\n true => sustainStatus[i][j];\n }\n }\n }\n}\n\nfun void sustainOff()\n{\n false => sustain;\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n false => sustainStatus[i][j];\n if(!lp.keyDown[i][j])\n {\n lp.setGridLight(i, j, 0);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (rawGain - 32) \/ 95.0) => targetGain;\n rawGain => targetGain;\n\n for(0 => int i; i < 8; i++)\n {\n for(0 => int j; j < 8; j++)\n {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n }\n }\n}\n\nfun void sustainListener()\n{\n wm.event(\"\/wii\/1\/button\/B,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sustainOff();\n }\n else\n {\n sustainOn();\n }\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,i\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n if(e.getInt() == 0)\n {\n sostenutoOff();\n }\n else\n {\n sostenutoOn();\n }\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true)\n {\n e => now;\n while(e.nextMsg() != 0)\n {\n Math.max(0.0, e.getFloat() - 0.22) => rawGain;\n chout <= rawGain <= IO.newline();\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n \/\/ 8000 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true)\n {\n 1::second => now;\n }\n}\n\nsetup();\n\nwhile(true)\n{\n 100::ms => now;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"4854b88bc52cbf0522e2efaed49eb42059dce938","subject":"Update chordProgression","message":"Update chordProgression\n\nmodulation added\n\\>chuck chordProgression\n1. send chords out (key\/root\/type)\n2. play chords in Rhodey\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"vi\"],\n [\"bV\",\"bv\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord iii;\nChord III;\nChord IV;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi],[[0.1,0.1,0.1,0.3,0.3,0.1],[0.1,0.1,0.1,0.1,0.1,0.5]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[I,iii,III,V,vi],[[0.1,0.1,0.3,0.4,0.1],[0.1,0.4,0.3,0.1,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi],[[0.6,0.4],[0.3,0.7]]);\nIV.init(5,0,[I,V,III],[[0.3,0.6,0.1],[0.2,0.5,0.3]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V,vi],[[0.1,0.3,0.1,0.3,0.1,0.1],[0.1,0.2,0.2,0.2,0.2,0.1]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI],[[1.0],[1.0]]);\nIII.setModulation([[VIsus4,VI]],[-3],[I]);\nI.setModulation([[VI,II],[I7,IV]],[2,5],[I,I]);\nI @=> current;\nRhodey instruments[4];\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n0=>int key;\nwhile (true)\n{\n <<< \"Chord Name: \", current.toString() >>>;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNotesWithin()@=>int notes[];\n for (0=>int j;j<4;j++)\n {\n 0.5::second=>now;\n for (0=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n 0.2=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n 0.1=>instruments[i].noteOn;\n }\n }\n if (current.getModulationTarget()!=null&&Math.random2f(0,1)<0.9)\n {\n\n current.getModulationSequence()@=>Chord sq[][];\n current.getModulationTarget()@=>int keys[];\n current.getModulationChord()@=>Chord chords[];\n Math.random2f(0,sq.cap()) $ int =>int choice;\n sq[choice]@=>Chord chordSq[];\n keys[choice]=>int keyChange;\n chords[choice]@=>Chord modChord;\n for (0=>int i; i current;\n <<< \"Chord Name: \", current.toString() >>>;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNotesWithin()@=>int notes[];\n for (0=>int j;j<4;j++)\n {\n 0.5::second=>now;\n for (0=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n 0.2=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n 0.1=>instruments[i].noteOn;\n }\n }\n }\n modChord.getNextChord()@=>current;\n (key+keyChange+12)%12=>key;\n }\n else\n {\n current.getNextChord()@=>current;\n }\n}\n\n\n","old_contents":"class Chord\n{\n 0=>int style; \n Chord @ next[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(0);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return this;\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"vi\"],\n [\"bV\",\"bv\"],\n [\"V\",\"v\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun int[] getNotesWithin()\n {\n if (type==0)\n {\n return [root,root+4,root+7];\n }\n if (type==1)\n {\n return [root,root+3,root+7];\n }\n if (type==2)\n {\n return [root,root+3,root+6];\n }\n return null;\n }\n}\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord previous;\nChord current;\nChord I;\nChord ii;\nChord iii;\nChord III;\nChord IV;\nChord V;\nChord V7;\nChord vi;\nI.init(0,0,[I,ii,III,IV,V,vi],[[0.1,0.1,0.1,0.3,0.3,0.1],[0.1,0.1,0.1,0.1,0.1,0.5]]);\nii.init(2,1,[I,iii,III,V,vi],[[0.1,0.1,0.3,0.4,0.1],[0.1,0.4,0.3,0.1,0.1]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi],[[0.6,0.4],[0.3,0.7]]);\nIV.init(5,0,[I,V,III],[[0.3,0.6,0.1],[0.2,0.5,0.3]]);\nV.init(7,0,[I,vi,ii,iii],[[0.5,0.2,0.1,0.2],[0.3,0.4,0.1,0.2]]);\nvi.init(9,1,[I,ii,iii,IV,V,vi],[[0.1,0.3,0.1,0.3,0.1,0.1],[0.1,0.2,0.2,0.2,0.2,0.1]]);\nI @=> current;\nRhodey instruments[4];\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\nwhile (true)\n{\n <<< \"Chord Name: \", current.toString() >>>;\n 0=>int key;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNotesWithin()@=>int notes[];\n for (0=>int j;j<4;j++)\n { \n 0.7::second=>now;\n for (0=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+key+(notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n 0.2=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n 0.1=>instruments[i].noteOn;\n }\n }\n current.getNextChord(1)@=>Chord temp;\n while (temp==previous)\n {\n current.getNextChord(1)@=>temp;\n }\n current @=> previous;\n temp @=> current;\n}\n\n\n\n\n\n\n\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"24ba5a7bc4e460738fcd21fef062c1393394b8e5","subject":"Update common_functions.ck","message":"Update common_functions.ck\n\nhaha, changing array references tripped me up.","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/common_functions.ck","new_file":"utility_functions\/common_functions.ck","new_contents":"\/\/ Machine.add(\"utilities.ck\");\n\n\/* \n definitions\n\n fun void repr_int_array(int arr[]){}\n fun void repr_string_array(string arr[]){}\n \n fun int random_from(int arr[]){}\n fun int inArray(int token, int arr[]){}\n fun int indexOfClosest(int ival, int arr[]){}\n fun int to_note(string str){}\n fun int[] join_int_arrays(int arr1[], int arr2[]){}\n fun int[] set_from(int arr[]){}\n fun int[] randomArray_from(int arr[], int length){}\n fun int[] range(int start, int end){}\n fun int[] narray(int start, int next, int up_to){}\n fun int[] expand_scale(int scale[], int start_stop[]){ \n fun int[][] stepify(string sequence_data[]){}\n \n fun float average(int arr[]){}\n \n fun string repr(int arr[]){}\n fun string repr(string arr[]){}\n fun string[] split(string arr, string token){}\n \n fun SndBuf load_sample(string wavname){}\n\n \n https:\/\/gist.github.com\/anonymous\/7206152\n \n*\/ \n\n\n\nfun string[] split_str(string str, string token){\n\n string collect[0];\n int pos;\n int pos2;\n while( str.find(token) >0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] join_int_arrays(int arr1[], int arr2[]){\n [arr1, arr2] @=> int arr[][];\n int new_arr[0];\n for(0 => int j; j int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] join_int_arrays(int arr1[], int arr2[]){\n for(0 => int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] randomArray_from(int arr[], int length){\n \/\/ return new array of capacity length chosing elements from arr\n int generated_arr[0];\n for(0 => int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_int_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n","old_contents":"\/\/ Machine.add(\"utilities.ck\");\n\n\/* \n definitions\n\n fun void repr_int_array(int arr[]){}\n fun void repr_int_array(string arr[]){}\n \n fun int random_from(int arr[]){}\n fun int inArray(int token, int arr[]){}\n fun int indexOfClosest(int ival, int arr[]){}\n fun int to_note(string str){}\n fun int[] randomArray_from(int arr[], int length){}\n fun int[] range(int start, int end){}\n fun int[] narray(int start, int next, int up_to){}\n fun int[][] stepify(string sequence_data[]){}\n \n fun float average(int arr[]){}\n \n fun string repr(int arr[]){}\n fun string repr(string arr[]){}\n fun string[] split(string arr, string token){}\n \n fun SndBuf load_sample(string wavname){}\n\n \n https:\/\/gist.github.com\/anonymous\/7206152\n \n*\/ \n\n\n\nfun string[] split_str(string str, string token){\n\n string collect[0];\n int pos;\n int pos2;\n while( str.find(token) >0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] randomArray_from(int arr[], int length){\n \/\/ return new array of capacity length chosing elements from arr\n int generated_arr[0];\n for(0 => int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_int_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"7a644655d6839f12945af4711db1b5930e2f4cd4","subject":"Update bassdrum_electronic_deepboom.ck","message":"Update bassdrum_electronic_deepboom.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electronic_deepboom.ck","new_file":"patches\/percussion\/bassdrum_electronic_deepboom.ck","new_contents":"\/\/ Assignment 7 drumCircleDSP\npublic class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 310, -.98, 1.0,50,-.6, 11.0, 1.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 621::ms, 0.0, 135::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 181::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n SinOsc form => volE => LPF boom => PoleZero dc => bdmast; \n dc.blockZero(0.992);\n 70 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(1.3);\n 41::samp => now;\n\n \/\/ advance time\n if (now > (start + 170::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\nKickSynC kick1;\n\nkick1.bdmast => dac;\nkick1.trigger(1.3);\n\n1::second => now;\n\n","old_contents":"\/\/ Assignment 7 drumCircleDSP\n\npublic class KickSynC{\n\n Gain bdmaster2 => dac;\n bdmaster2.gain(0.02);\n\n fun void trigger(float volume){\n \/* this makes it possible to trigger \n the bassdrum in a new thread *\/\n spork ~ s_do_kick(volume);\n }\n\n fun void s_do_kick(float volume){\n\n 3850 => float frequency;\n\n SinOsc bd_osc => \n Gain preAmp => HPF bf => ADSR volEnv => \n PoleZero dc => LPF highs => bdmaster2;\n \n dc.blockZero(0.99);\n bf.freq(50);\n bf.Q(4.1);\n highs.freq(332);\n \n volEnv.set( 1::ms, 181::ms, 0.3, 35::ms );\n bdmaster2.gain(volume);\n\n 1 => int fa;\n 44 => int fd;\n 50 => int fs;\n 120 => int fr;\n\n 44100\/frequency => float grain;\n\n Step s5 => ADSR pitchEnv => blackhole;\n pitchEnv.set(fa::ms, (fd\/1.2)::ms, fs\/100, fr::ms);\n pitchEnv.keyOn(1);\n volEnv.keyOn(1);\n (140)::ms + now => time later;\n while(now < later)\n {\n 850 => int min_freq;\n 51 => int bass_freq;\n ((pitchEnv.last()*220) + min_freq) $ int => int pitch_curve;\n Math.max(pitch_curve, bass_freq) - 800.0 => float debug_freq => bd_osc.freq;\n\n grain::samp => now;\n\n if( now > later){\n (120)::ms => now;\n volEnv.keyOff(1);\n pitchEnv.keyOff(1);\n }\n }\n\n\n\n 1.5::second => now;\n bd_osc =< preAmp;\n\n }\n\n}\n\nKickSynC kick1;\n\nkick1.trigger(0.5);\n\n1::second => now;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"7a6ec2e4f43922f2af01bf4e505dc7c6be9ce872","subject":"Update common_functions.ck","message":"Update common_functions.ck\n\nadded `fun int[] set_from(int arr[])`","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/common_functions.ck","new_file":"utility_functions\/common_functions.ck","new_contents":"\/\/ Machine.add(\"utilities.ck\");\n\n\/* \n definitions\n\n fun void repr_int_array(int arr[]){}\n fun void repr_string_array(string arr[]){}\n \n fun int random_from(int arr[]){}\n fun int inArray(int token, int arr[]){}\n fun int indexOfClosest(int ival, int arr[]){}\n fun int to_note(string str){}\n fun int[] set_from(int arr[]){}\n fun int[] randomArray_from(int arr[], int length){}\n fun int[] range(int start, int end){}\n fun int[] narray(int start, int next, int up_to){}\n fun int[] expand_scale(int scale[], int start_stop[]){ \n fun int[][] stepify(string sequence_data[]){}\n \n fun float average(int arr[]){}\n \n fun string repr(int arr[]){}\n fun string repr(string arr[]){}\n fun string[] split(string arr, string token){}\n \n fun SndBuf load_sample(string wavname){}\n\n \n https:\/\/gist.github.com\/anonymous\/7206152\n \n*\/ \n\n\n\nfun string[] split_str(string str, string token){\n\n string collect[0];\n int pos;\n int pos2;\n while( str.find(token) >0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] randomArray_from(int arr[], int length){\n \/\/ return new array of capacity length chosing elements from arr\n int generated_arr[0];\n for(0 => int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] randomArray_from(int arr[], int length){\n \/\/ return new array of capacity length chosing elements from arr\n int generated_arr[0];\n for(0 => int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"7de8207284bb7c7b7b40c4ae7ac3e3878cafbfa4","subject":"added meaningful comments","message":"added meaningful comments\n","repos":"zeffii\/ChucKScripts","old_file":"patches\/melodic\/WindChime_v2.ck","new_file":"patches\/melodic\/WindChime_v2.ck","new_contents":"\/\/WindChime.ck\n\npublic class WindChime {\n\n\n 0.995 => float block_value;\n PoleZero dcCorrector; dcCorrector.blockZero(block_value);\n\n Mix2 mout;\n NRev rvb => dcCorrector => mout;\n rvb.mix(0.12);\n mout.gain(0.133);\n\n dur a, d, s, r;\n float s_level;\n\n float midint;\n 0.02 => float chime_vol; \/\/ default\n rvb => DelayA td => rvb;\n td.delay(70::ms);\n td.max(70::ms);\n td.gain(0.33);\n\n fun void set_chime_vol(float chime_vol){\n chime_vol => this.chime_vol;\n }\n\n fun void set_adsr(dur a, dur d, dur s, float s_level, dur r){\n a => this.a;\n d => this.d;\n s => this.s;\n s_level => this.s_level;\n r => this.r;\n }\n\n fun void s_play_note(){\n SinOsc s => ADSR env => rvb;\n SinOsc s2 => env;\n SinOsc s3 => env;\n SinOsc s0 => env;\n SinOsc m => s;\n\n env => Pan2 p;\n Math.random2f( 0.8, -0.8 ) => p.pan;\n NRev rvs[2];\n\n p.left => rvs[0] => mout.left;\n p.right => rvs[1] => mout.right;\n for(0 => int i; i Std.mtof => float gfreq => s.freq;\n s2.freq((gfreq*2) + 0.012);\n s2.freq() * Math.random2f(.922, 1.052) => s2.freq;\n s2.gain(chime_vol*0.8);\n s3.freq(gfreq*0.5);\n s3.freq() * Math.random2f(.988, 1.022) => s3.freq;\n s3.gain(chime_vol*.22);\n s0.freq(gfreq*4\/(midint\/17.65));\n s0.freq() * Math.random2f(.992, 1.022) => s0.freq;\n s0.gain(chime_vol*.052);\n m.freq(2 * gfreq);\n m.gain(3000);\n\n \/\/ Envelope config\n \/\/ maybe these should be randomized too\n env.set( a, d, s_level, r );\n env.keyOn(); \n (this.a + this.d + this.s) => now; \n env.keyOff(); \n this.r => now;\n }\n\n fun void play_note(float midint){\n midint => this.midint;\n spork ~ s_play_note();\n }\n\n \/\/ this sets a default, incase i forget to\n set_adsr( 3::ms, 291::ms, 31::ms, .620, 335::ms ); \/\/a, d, s, r\n\n}\n\n\nWindChime wc;\nwc.set_chime_vol(0.37);\n\n\/\/ this enforces the overal loudness of the patch, else it would\n\/\/ tend to go into a feedback gain. I didn't investigate why\nADSR sound_sculpt[2];\nwc.mout.left => sound_sculpt[0] => dac.left;\nwc.mout.right => sound_sculpt[1] => dac.right;\n\nsound_sculpt[0].set( 0::ms, 0::ms, 1.0, 3235::ms ); \/\/a, d, s, r\nsound_sculpt[1].set( 0::ms, 0::ms, 1.0, 3235::ms ); \/\/a, d, s, r\nsound_sculpt[0].keyOn();\nsound_sculpt[1].keyOn();\n\n36 => int num_chimes;\n120.0 => float start_note;\n1 \/ 1.4 => float rate; \/\/ speed at which this traverses the chime\n\n\/\/ simulate fingers traveling along chimes.\nfor(0 => int i; inow;\n}\n\nsound_sculpt[0].keyOff();\nsound_sculpt[1].keyOff();\n\n\/\/ prevent clicks\n7::second => now;\n","old_contents":"\/\/WindChime.ck\n\npublic class WindChime {\n\n\n 0.995 => float block_value;\n PoleZero dcCorrector; dcCorrector.blockZero(block_value);\n\n Mix2 mout;\n NRev rvb => dcCorrector => mout;\n rvb.mix(0.12);\n mout.gain(0.133);\n\n dur a, d, s, r;\n float s_level;\n\n float midint;\n 0.02 => float chime_vol; \/\/ default\n rvb => DelayA td => rvb;\n td.delay(70::ms);\n td.max(70::ms);\n td.gain(0.33);\n\n fun void set_chime_vol(float chime_vol){\n chime_vol => this.chime_vol;\n }\n\n fun void set_adsr(dur a, dur d, dur s, float s_level, dur r){\n a => this.a;\n d => this.d;\n s => this.s;\n s_level => this.s_level;\n r => this.r;\n }\n\n fun void s_play_note(){\n SinOsc s => ADSR env => rvb;\n SinOsc s2 => env;\n SinOsc s3 => env;\n SinOsc s0 => env;\n SinOsc m => s;\n\n env => Pan2 p;\n Math.random2f( 0.8, -0.8 ) => p.pan;\n NRev rvs[2];\n\n p.left => rvs[0] => mout.left;\n p.right => rvs[1] => mout.right;\n for(0 => int i; i Std.mtof => float gfreq => s.freq;\n s2.freq((gfreq*2) + 0.012);\n s2.freq() * Math.random2f(.922, 1.052) => s2.freq;\n s2.gain(chime_vol*0.8);\n s3.freq(gfreq*0.5);\n s3.freq() * Math.random2f(.988, 1.022) => s3.freq;\n s3.gain(chime_vol*.22);\n s0.freq(gfreq*4\/(midint\/17.65));\n s0.freq() * Math.random2f(.992, 1.022) => s0.freq;\n s0.gain(chime_vol*.052);\n m.freq(2 * gfreq);\n m.gain(3000);\n\n \/\/ Envelope config\n \/\/ maybe these should be randomized too\n env.set( a, d, s_level, r );\n env.keyOn(); \n (this.a + this.d + this.s) => now; \n env.keyOff(); \n this.r => now;\n }\n\n fun void play_note(float midint){\n midint => this.midint;\n spork ~ s_play_note();\n }\n\n \/\/ this sets a default, incase i forget to\n set_adsr( 2::ms, 291::ms, 31::ms, .620, 335::ms ); \/\/a, d, s, r\n\n}\n\nWindChime wc;\nADSR sound_sculpt[2];\n36 => int num_chimes;\nwc.mout.left => sound_sculpt[0] => dac.left;\nwc.mout.right => sound_sculpt[1] => dac.right;\nsound_sculpt[0].set( 0::ms, 0::ms, 1.0, 3235::ms ); \/\/a, d, s, r\nsound_sculpt[1].set( 0::ms, 0::ms, 1.0, 3235::ms ); \/\/a, d, s, r\nwc.set_chime_vol(0.37);\nsound_sculpt[0].keyOn();\nsound_sculpt[1].keyOn();\n120.0 => float start_note;\n1 \/ 1.4 => float rate;\nfor(0 => int i; inow;\n}\nsound_sculpt[0].keyOff();\nsound_sculpt[1].keyOff();\n\/\/ prevent clicks\n7::second => now;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"b9f6d94a3e30438424d9378fd2cc30f8e323d556","subject":"sounds better","message":"sounds better\n\nthis way\n","repos":"zeffii\/ChucKScripts","old_file":"patches\/melodic\/WindChime.ck","new_file":"patches\/melodic\/WindChime.ck","new_contents":"\/\/WindChime.ck\n\npublic class WindChime {\n\n Mix2 mout;\n NRev rvb => mout;\n rvb.mix(0.22);\n mout.gain(0.3);\n dur a;\n dur d;\n dur s;\n float s_level;\n dur r;\n float midint;\n 0.02 => float chime_vol; \/\/ default\n\n fun void set_chime_vol(float chime_vol){\n chime_vol => this.chime_vol;\n }\n\n fun void set_adsr(dur a, dur d, dur s, float s_level, dur r){\n a => this.a;\n d => this.d;\n s => this.s;\n s_level => this.s_level;\n r => this.r;\n }\n\n fun void s_play_note(){\n SinOsc s => ADSR env => rvb;\n SinOsc m => s;\n s.sync(2);\n s.gain(chime_vol);\n midint => Std.mtof => float gfreq => s.freq;\n m.freq(2 * gfreq);\n m.gain(3000);\n\n \/\/ Envelope config\n env.set( a, d, s_level, r );\n env.keyOn(); \n (this.a + this.d + this.s) => now;\n env.keyOff(); \n this.r => now;\n }\n\n fun void play_note(float midint){\n midint => this.midint;\n spork ~ s_play_note();\n }\n\n \/\/ this sets a defult, incase i forget to\n set_adsr( 2::ms, 281::ms, 191::ms, .590, 35::ms ); \/\/a, d, s, r\n\n}\n\nWindChime wc;\nwc.mout => dac;\nwc.set_chime_vol(0.08);\n\n120.0 => float start_note;\nfor(0 => int i; i<25; i++){\n wc.play_note(start_note-(i*0.6));\n .11::second =>now;\n}\n\n\/\/ prevent clicks\n2::second => now;\n","old_contents":"\/\/WindChime.ck\n\npublic class WindChime {\n\n Mix2 mout;\n NRev rvb => mout;\n rvb.mix(0.02);\n mout.gain(0.3);\n dur a;\n dur d;\n dur s;\n float s_level;\n dur r;\n float midint;\n 0.02 => float chime_vol; \/\/ default\n\n fun void set_chime_vol(float chime_vol){\n chime_vol => this.chime_vol;\n }\n\n fun void set_adsr(dur a, dur d, dur s, float s_level, dur r){\n a => this.a;\n d => this.d;\n s => this.s;\n s_level => this.s_level;\n r => this.r;\n }\n\n fun void s_play_note(){\n SinOsc s => ADSR env => rvb;\n SinOsc m => s;\n s.sync(2);\n s.gain(chime_vol);\n midint => Std.mtof => float gfreq => s.freq;\n m.freq(2 * gfreq);\n m.gain(3000);\n\n \/\/ Envelope config\n env.set( a, d, s_level, r );\n env.keyOn(); \n (this.a + this.d + this.s) => now;\n env.keyOff(); \n r => now;\n }\n\n fun void play_note(float midint){\n midint => this.midint;\n spork ~ s_play_note();\n }\n\n \/\/ this sets a defult, incase i forget to\n set_adsr( 2::ms, 61::ms, 311::ms, .50, 235::ms ); \/\/a, d, s, r\n\n}\n\nWindChime wc;\nwc.mout => dac;\nwc.set_chime_vol(0.08);\n\n90.0 => float start_note;\nfor(0 => int i; i<25; i++){\n wc.play_note(start_note-(i*0.6));\n .12::second =>now;\n}\n\n\/\/ prevent clicks\n2::second => now;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"5e99f175b1a55b8d5e22781e8075e71e6b88671c","subject":"haha more accurate","message":"haha more accurate\n\nlistening to tonebender.\n","repos":"zeffii\/ChucKScripts","old_file":"patches\/melodic\/WindChime.ck","new_file":"patches\/melodic\/WindChime.ck","new_contents":"\/\/WindChime.ck\n\npublic class WindChime {\n\n Mix2 mout;\n NRev rvb => mout;\n rvb.mix(0.22);\n mout.gain(0.3);\n dur a;\n dur d;\n dur s;\n float s_level;\n dur r;\n float midint;\n 0.02 => float chime_vol; \/\/ default\n\n fun void set_chime_vol(float chime_vol){\n chime_vol => this.chime_vol;\n }\n\n fun void set_adsr(dur a, dur d, dur s, float s_level, dur r){\n a => this.a;\n d => this.d;\n s => this.s;\n s_level => this.s_level;\n r => this.r;\n }\n\n fun void s_play_note(){\n SinOsc s => ADSR env => rvb;\n SinOsc s2 => env;\n SinOsc m => s;\n\n env => Pan2 p;\n Math.random2f( 0.8, -0.8 ) => p.pan;\n NRev rvs[2];\n\n p.left => rvs[0] => mout.left;\n p.right => rvs[1] => mout.right;\n for(0 => int i; i Std.mtof => float gfreq => s.freq;\n s2.freq(gfreq + 0.012);\n s2.gain(chime_vol);\n m.freq(2 * gfreq);\n m.gain(3000);\n\n \/\/ Envelope config\n env.set( a, d, s_level, r );\n env.keyOn(); \n (this.a + this.d + this.s) => now;\n env.keyOff(); \n this.r => now;\n }\n\n fun void play_note(float midint){\n midint => this.midint;\n spork ~ s_play_note();\n }\n\n \/\/ this sets a defult, incase i forget to\n set_adsr( 2::ms, 151::ms, 121::ms, .890, 35::ms ); \/\/a, d, s, r\n\n}\n\nWindChime wc;\nwc.mout => dac;\nwc.set_chime_vol(0.18);\n\n120.0 => float start_note;\nfor(0 => int i; i<25; i++){\n wc.play_note(start_note-(i*0.6));\n (0.12 )::second =>now;\n}\n\n\/\/ prevent clicks\n2::second => now;\n","old_contents":"\/\/WindChime.ck\n\npublic class WindChime {\n\n Mix2 mout;\n NRev rvb => mout;\n rvb.mix(0.22);\n mout.gain(0.3);\n dur a;\n dur d;\n dur s;\n float s_level;\n dur r;\n float midint;\n 0.02 => float chime_vol; \/\/ default\n\n fun void set_chime_vol(float chime_vol){\n chime_vol => this.chime_vol;\n }\n\n fun void set_adsr(dur a, dur d, dur s, float s_level, dur r){\n a => this.a;\n d => this.d;\n s => this.s;\n s_level => this.s_level;\n r => this.r;\n }\n\n fun void s_play_note(){\n SinOsc s => ADSR env => rvb;\n SinOsc m => s;\n s.sync(2);\n s.gain(chime_vol);\n midint => Std.mtof => float gfreq => s.freq;\n m.freq(2 * gfreq);\n m.gain(3000);\n\n \/\/ Envelope config\n env.set( a, d, s_level, r );\n env.keyOn(); \n (this.a + this.d + this.s) => now;\n env.keyOff(); \n this.r => now;\n }\n\n fun void play_note(float midint){\n midint => this.midint;\n spork ~ s_play_note();\n }\n\n \/\/ this sets a defult, incase i forget to\n set_adsr( 2::ms, 281::ms, 191::ms, .590, 35::ms ); \/\/a, d, s, r\n\n}\n\nWindChime wc;\nwc.mout => dac;\nwc.set_chime_vol(0.08);\n\n120.0 => float start_note;\nfor(0 => int i; i<25; i++){\n wc.play_note(start_note-(i*0.6));\n .11::second =>now;\n}\n\n\/\/ prevent clicks\n2::second => now;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"a9eaf010c1871f34d8a835346459c127f89c4253","subject":"Update common_functions.ck","message":"Update common_functions.ck","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/common_functions.ck","new_file":"utility_functions\/common_functions.ck","new_contents":"\/\/ Machine.add(\"utilities.ck\");\n\n\/* \n definitions\n\n fun void repr_int_array(int arr[]){}\n fun void repr_string_array(string arr[]){}\n \n fun int random_from(int arr[]){}\n fun int inArray(int token, int arr[]){}\n fun int indexOfClosest(int ival, int arr[]){}\n fun int to_note(string str){}\n fun int[] join_int_arrays(int arr1[], int arr2[]){}\n fun int[] repeat_int_array(int arr[], int num_times){}\n fun int[] set_from(int arr[]){}\n fun int[] randomArray_from(int arr[], int length){}\n fun int[] range(int start, int end){}\n fun int[] narray(int start, int next, int up_to){}\n fun int[] expand_scale(int scale[], int start_stop[]){ \n fun int[][] stepify(string sequence_data[]){}\n \n fun float average(int arr[]){}\n \n fun string repr(int arr[]){}\n fun string repr(string arr[]){}\n fun string[] split(string arr, string token){}\n \n fun SndBuf load_sample(string wavname){}\n\n \n https:\/\/gist.github.com\/anonymous\/7206152\n \n*\/ \n\n\n\nfun string[] split_str(string str, string token){\n\n string collect[0];\n int pos;\n int pos2;\n while( str.find(token) >0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] join_int_arrays(int arr1[], int arr2[]){\n [arr1, arr2] @=> int arr[][];\n int new_arr[0];\n for(0 => int j; j int i; i int j; j int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] join_int_arrays(int arr1[], int arr2[]){\n [arr1, arr2] @=> int arr[][];\n int new_arr[0];\n for(0 => int j; j int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float wiiAccel;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.green => int keyOnColor;\nLaunchpadColor.red => int keySustainColor;\nLaunchpadColor.orange => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 82.4068867, 12.0) @=> oscBank;\n\n if(prompt) {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n Launchpad.Launchpad(lpChannel) @=> lp;\n } else {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nOscSend toUI;\ntoUI.setHost(\"localhost\", 9000);\n\nfun void sendOsc(string path, int val) {\n toUI.startMsg(path, \"i\");\n val => toUI.addInt;\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone) { return; }\n else if(toneChoice == 0) { oscBank.setPatch(\"SinOsc\"); }\n else if(toneChoice == 1) { oscBank.setPatch(\"SqrOsc\"); }\n else if(toneChoice == 2) { oscBank.setPatch(\"SawOsc\"); }\n else if(toneChoice == 3) { oscBank.setPatch(\"TriOsc\"); }\n else { return; } \n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void setSostenuto(int enabled) {\n enabled => sostenuto;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] && enabled => sostenutoStatus[x][y];\n if(!enabled && !lp.keyDown[x][y] && !sustainStatus[x][y]) {\n lp.setGridLight(x, y, 0);\n sendOsc(\"\/grid\/noteOff\", y * 8 + x);\n }\n }\n }\n}\n\nfun void setSustain(int enabled) {\n enabled => sustain;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] => int down;\n down && enabled => sustainStatus[x][y];\n if(!down && !sostenutoStatus[x][y]) {\n lp.setGridLight(x, y, 0);\n sendOsc(\"\/grid\/noteOff\", y * 8 + x);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (wiiAccel - 32) \/ 95.0) => targetGain;\n wiiAccel => targetGain;\n\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n sendOsc(\"\/grid\/noteOn\", lp.e.row * 8 + lp.e.column);\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n sendOsc(\"\/grid\/noteOff\", lp.e.row * 8 + lp.e.column);\n }\n }\n}\n\nfun void sustainListener() {\n wm.event(\"\/wii\/1\/button\/B,f\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSustain(e.getFloat() != 0);\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,f\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSostenuto(e.getFloat() != 0);\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n Math.max(0.0, e.getFloat() - 0.22) => wiiAccel;\n \/\/ chout <= wiiAccel <= IO.newline();\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n \/\/ 8000 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true) { 1::second => now; }\n}\n\nsetup();\nwhile(true) { 100::ms => now; }\n","old_contents":"OscRecv wm;\nLaunchpad lp;\nOscBank oscBank;\n\nfalse => int prompt;\n50::samp => dur gainResolution;\n0.0016 => float releaseDecay;\n0.00001 => float sustainDecay;\n0.00001 => float sostenutoDecay;\n0.01 => float pressAttack;\n0.80 => float maxNoteGain;\n0.0 => float wiiAccel;\n0 => int currentTone;\nfalse => int sustain;\n int sustainStatus[8][8];\nfalse => int sostenuto;\n int sostenutoStatus[8][8];\n0 => int lpChannel;\n\nLaunchpadColor.green => int keyOnColor;\nLaunchpadColor.red => int keySustainColor;\nLaunchpadColor.orange => int keySostenutoColor;\nLaunchpadColor.red => int toneChoiceColor;\n\nfun void setup()\n{\n OscBank.OscBank(8, 8, 1, 5, 82.4068867, 12.0) @=> oscBank;\n\n if(prompt) {\n intPrompt(\"Enter Midi Channel for Launchpad input: \") => lpChannel;\n Launchpad.Launchpad(lpChannel) @=> lp;\n } else {\n Launchpad.Launchpad(0) @=> lp;\n }\n\n me.yield();\n lp.clear();\n lp.setGridLight(8, currentTone, toneChoiceColor);\n\n spork ~ launchpadListener();\n spork ~ wiiListener();\n spork ~ updateGains();\n}\n\nOscSend toUI;\ntoUI.setHost(\"localhost\", 9000);\n\nfun void sendOsc(string path, int val) {\n toUI.startMsg(path, \"i\");\n val => toUI.addInt;\n <<< val >>>;\n}\n\nfun void setTone(int toneChoice)\n{\n if(toneChoice == currentTone) { return; }\n else if(toneChoice == 0) { oscBank.setPatch(\"SinOsc\"); }\n else if(toneChoice == 1) { oscBank.setPatch(\"SqrOsc\"); }\n else if(toneChoice == 2) { oscBank.setPatch(\"SawOsc\"); }\n else if(toneChoice == 3) { oscBank.setPatch(\"TriOsc\"); }\n else { return; } \n\n lp.setGridLight(8, currentTone, 0);\n lp.setGridLight(8, toneChoice, toneChoiceColor);\n toneChoice => currentTone;\n}\n\nfun void setSostenuto(int enabled) {\n enabled => sostenuto;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] && enabled => sostenutoStatus[x][y];\n if(!enabled && !lp.keyDown[x][y] && !sustainStatus[x][y]) {\n lp.setGridLight(x, y, 0);\n sendOsc(\"\/grid\/noteOff\", y * 8 + x);\n }\n }\n }\n}\n\nfun void setSustain(int enabled) {\n enabled => sustain;\n for(0 => int x; x < 8; x++) {\n for(0 => int y; y < 8; y++) {\n lp.keyDown[x][y] => int down;\n down && enabled => sustainStatus[x][y];\n if(!down && !sostenutoStatus[x][y]) {\n lp.setGridLight(x, y, 0);\n sendOsc(\"\/grid\/noteOff\", y * 8 + x);\n }\n }\n }\n}\n\nfun void release(int column, int row)\n{\n Math.max(oscBank.gains[column][row].gain() - releaseDecay, 0.00)\n => oscBank.gains[column][row].gain;\n}\n\nfun void updateSustain(int column, int row, float targetGain)\n{\n if(sustain && sustainStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sustainDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n release(column, row);\n }\n}\n\nfun void updateSostenuto(int column, int row, float targetGain)\n{\n if(sostenuto && sostenutoStatus[column][row])\n {\n Math.max(oscBank.gains[column][row].gain() - sostenutoDecay, 0.00)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSustain(column, row, targetGain);\n }\n}\n\nfun void update(int column, int row, float targetGain)\n{\n if(lp.keyDown[column][row] && targetGain > oscBank.gains[column][row].gain())\n {\n Math.min(oscBank.gains[column][row].gain() + pressAttack, maxNoteGain)\n => oscBank.gains[column][row].gain;\n }\n else\n {\n updateSostenuto(column, row, targetGain);\n }\n}\n\nfun void updateGains()\n{\n float targetGain;\n while(true) {\n \/\/ Math.max(0.0, (wiiAccel - 32) \/ 95.0) => targetGain;\n wiiAccel => targetGain;\n\n for(0 => int i; i < 8; i++) {\n for(0 => int j; j < 8; j++) {\n update(i, j, targetGain);\n }\n }\n\n gainResolution => now;\n }\n}\n\nfun int intPrompt(string msg)\n{\n int in;\n ConsoleInput cin;\n StringTokenizer tok;\n cin.prompt(msg) => now;\n while(cin.more())\n {\n tok.set(cin.getLine());\n while(tok.more())\n {\n Std.atoi(tok.next()) => in;\n }\n }\n return in;\n}\n\nfun void launchpadListener()\n{\n while(true)\n {\n lp.e => now;\n\n \/\/ ignore button presses that are not on the grid\n if(lp.e.column < 0 || lp.e.column > 8) continue;\n if(lp.e.row < 0 || lp.e.row > 7) continue;\n\n if(lp.e.column == 8)\n {\n if(lp.e.velocity == 127)\n {\n setTone(lp.e.row);\n }\n }\n else if(lp.e.velocity == 127)\n {\n if(sustain)\n {\n true => sustainStatus[lp.e.column][lp.e.row];\n }\n lp.setGridLight(lp.e.column, lp.e.row, keyOnColor);\n 1 => oscBank.bank[lp.e.column][lp.e.row].op;\n sendOsc(\"\/grid\/noteOn\", lp.e.row * 8 + lp.e.column);\n }\n else if(sostenuto && sostenutoStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySostenutoColor);\n }\n else if(sustain && sustainStatus[lp.e.column][lp.e.row])\n {\n lp.setGridLight(lp.e.column, lp.e.row, keySustainColor);\n }\n else\n {\n lp.setGridLight(lp.e.column, lp.e.row, 0);\n sendOsc(\"\/grid\/noteOff\", lp.e.row * 8 + lp.e.column);\n }\n }\n}\n\nfun void sustainListener() {\n wm.event(\"\/wii\/1\/button\/B,i\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSustain(e.getInt() != 0);\n }\n }\n}\n\nfun void sostenutoListener()\n{\n wm.event(\"\/wii\/1\/button\/A,i\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n setSostenuto(e.getInt() != 0);\n }\n }\n}\n\nfun void accelListener()\n{\n wm.event(\"\/wii\/1\/accel\/pry\/3,f\") @=> OscEvent e;\n while(true) {\n e => now;\n while(e.nextMsg() != 0) {\n Math.max(0.0, e.getFloat() - 0.22) => wiiAccel;\n chout <= wiiAccel <= IO.newline();\n }\n }\n}\n\nfun void wiiListener()\n{\n 6449 => wm.port;\n \/\/ 8000 => wm.port;\n wm.listen();\n spork ~ sustainListener();\n spork ~ sostenutoListener();\n spork ~ accelListener();\n while(true) { 1::second => now; }\n}\n\nsetup();\nwhile(true) { 100::ms => now; }\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"de6ae12cad0b1027c121922fc7e60674ceeb6cce","subject":"Update to_stereo_wav_with_gainParams.ck","message":"Update to_stereo_wav_with_gainParams.ck","repos":"zeffii\/ChucKScripts","old_file":"wave_writer\/to_stereo_wav_with_gainParams.ck","new_file":"wave_writer\/to_stereo_wav_with_gainParams.ck","new_contents":"\/\/me.arg(0) => string filename;\n\/\/if( filename.length() == 0 ) \"foo.wav\" => filename;\n\ndac => Mix2 regulator => WvOut2 w => blackhole;\n\/\/\"data\/session\" => w.autoPrefix;\n\nregulator.gain(1.0);\n\"woooot.wav\" => w.wavFilename;\n1 => w.record;\n3::second => now;\n\n\/\/ everything in between gets recorded.\n\n\n0 => w.record;\nw.fileClose();\n","old_contents":"\/\/me.arg(0) => string filename;\n\/\/if( filename.length() == 0 ) \"foo.wav\" => filename;\n\ndac => Mix2 regulator => WvOut2 w => blackhole;\n\/\/\"data\/session\" => w.autoPrefix;\n\nregulator.gain(1.0);\n\"woooot.wav\" => w.wavFilename;\n1 => w.record;\n3::second => now;\n\n\/\/ everything in between gets recorded.\n\n\n0 => w.record;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"6362bc95f1ca175a1f6045028bce9af0ea331a25","subject":"Update bassdrum_electronic_deepboom3.ck","message":"Update bassdrum_electronic_deepboom3.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electronic_deepboom3.ck","new_file":"patches\/percussion\/bassdrum_electronic_deepboom3.ck","new_contents":"public class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume\/3.3);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 1590, -7.98, \n 0.05, 240, -.98, \n .17, 114, 0, \n .61, 54, 0, \n 1.8, 41.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 740::ms, 0.0, 125::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 281::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n Dyno comp => bdmast;\n comp.compress();\n SinOsc form => volE => LPF boom => PoleZero dc => comp; \n dc.blockZero(0.994);\n 432 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(.26);\n 21::samp => now;\n\n \/\/ advance time\n if (now > (start + 280::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\n\/*\n Usage docs\n\n KickSynC kick1;\n\n kick1.bdmast => dac;\n kick1.bdmast => NRev blunk => dac;\n blunk.gain(0.01);\n blunk.mix(0.2);\n\n for(0 => int i; i<5; i++){\n kick1.trigger(4.4);\n 0.5::second => now;\n }\n*\/\n","old_contents":"\/\/ with some example how to wire it up.\n\npublic class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume\/3.3);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 1590, -7.98, \n 0.05, 240, -.98, \n .17, 114, 0, \n .61, 54, 0, \n 1.8, 41.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 740::ms, 0.0, 125::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 281::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n Dyno comp => bdmast;\n comp.compress();\n SinOsc form => volE => LPF boom => PoleZero dc => comp; \n dc.blockZero(0.994);\n 432 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(.26);\n 21::samp => now;\n\n \/\/ advance time\n if (now > (start + 280::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\nKickSynC kick1;\n\nkick1.bdmast => dac;\nkick1.bdmast => NRev blunk => dac;\nblunk.gain(0.01);\nblunk.mix(0.2);\n\nfor(0 => int i; i<5; i++){\n kick1.trigger(4.4);\n 0.5::second => now;\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"a1a7eee4d9b7535320610cad1ad2cc13769cc1ac","subject":"test files names changed","message":"test files names changed\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"test\/stammer_test.ck","new_file":"test\/stammer_test.ck","new_contents":"Stammer stm => dac;\n2.0 => stm.set_freq;\nspork ~ stm.local_loop();\n\nSndBuf buf_1;\nSndBuf buf_2;\nme.dir() + \"\/..\/sounds\/test_sound_01.wav\" => buf_1.read;\nme.dir() + \"\/..\/sounds\/test_sound_02.wav\" => buf_2.read;\n\nbuf_2 => stm;\n10::second => now;\n\nbuf_2 =< stm;\nbuf_1 => stm;\n10::second => now;\n\nbuf_2 => stm;\n10::second => now;\n","old_contents":"Stammer stm => dac;\n2.0 => stm.set_freq;\nspork ~ stm.local_loop();\n\nSndBuf buf_1;\nSndBuf buf_2;\nme.dir() + \"\/..\/sounds\/ptaszek.wav\" => buf_1.read;\nme.dir() + \"\/..\/sounds\/c1_atlas.wav\" => buf_2.read;\n\nbuf_2 => stm;\n10::second => now;\n\nbuf_2 =< stm;\nbuf_1 => stm;\n10::second => now;\n\nbuf_2 => stm;\n10::second => now;\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"ChucK"} {"commit":"8842dc45220fd36333bc776ee3fcffea5242caa5","subject":"Update chuck_midi_in_to_notes_array.ck","message":"Update chuck_midi_in_to_notes_array.ck","repos":"zeffii\/ChucKScripts","old_file":"demo_files\/chuck_midi_in_to_notes_array.ck","new_file":"demo_files\/chuck_midi_in_to_notes_array.ck","new_contents":"\n\nMidiIn min;\nMidiMsg msg;\n\n\/\/ open midi receiver, exit on fail\nif ( !min.open(0) ) me.exit(); \n\nint notes[0];\nwhile( true )\n{\n \/\/ wait on midi event\n min => now;\n\n \/\/ receive midimsg(s)\n while( min.recv( msg ) )\n {\n \/\/ print content\n msg.data1 => int mode;\n msg.data2 => int note;\n msg.data3 => int volume;\n\n if (mode == 128) notes << note;\n \/\/else { [] @=> notes; }\n }\n if (notes.cap() > 0) {\n repr_int_array(notes);\n }\n int a[0] @=> notes;\n}\n\n\/\/ array\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"] @=> int notes[];\";\n chout <= IO.newline();\n}\n\n","old_contents":"\/\/ MidiIn min;\n\/\/ MidiMsg msg;\n\n\/\/ \/\/ open midi receiver, exit on fail\n\/\/ if ( !min.open(0) ) me.exit(); \n\n\/\/ while( true )\n\/\/ {\n\/\/ \/\/ wait on midi event\n\/\/ min => now;\n\n\/\/ \/\/ receive midimsg(s)\n\/\/ while( min.recv( msg ) )\n\/\/ {\n\/\/ \/\/ print content\n\/\/ <<< msg.data1, msg.data2, msg.data3 >>>;\n\/\/ }\n\/\/ }\n\nMidiIn min;\nMidiMsg msg;\n\n\/\/ open midi receiver, exit on fail\nif ( !min.open(0) ) me.exit(); \n\nint notes[0];\nwhile( true )\n{\n \/\/ wait on midi event\n min => now;\n\n \/\/ receive midimsg(s)\n while( min.recv( msg ) )\n {\n \/\/ print content\n msg.data1 => int mode;\n msg.data2 => int note;\n msg.data3 => int volume;\n\n if (mode == 128) notes << note;\n \/\/else { [] @=> notes; }\n }\n if (notes.cap() > 0) {\n repr_int_array(notes);\n }\n int a[0] @=> notes;\n}\n\n\/\/ array\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"] @=> int notes[];\";\n chout <= IO.newline();\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"022dbbfb00342162a276a636e0b24305686baccd","subject":"Update to_stereo_wav.ck","message":"Update to_stereo_wav.ck","repos":"zeffii\/ChucKScripts","old_file":"wave_writer\/to_stereo_wav.ck","new_file":"wave_writer\/to_stereo_wav.ck","new_contents":"\/\/me.arg(0) => string filename;\n\/\/if( filename.length() == 0 ) \"foo.wav\" => filename;\n\ndac => WvOut2 w => blackhole;\n\/\/\"data\/session\" => w.autoPrefix;\n\"woooot.wav\" => w.wavFilename;\n1 => w.record;\n3::second => now;\n\n\/\/ everything in between\n\n\n0 => w.record;\n","old_contents":"\/\/me.arg(0) => string filename;\n\/\/if( filename.length() == 0 ) \"foo.wav\" => filename;\n\ndac => Gain g => WvOut2 w => blackhole;\n\/\/\"data\/session\" => w.autoPrefix;\n\"woooot.wav\" => w.wavFilename;\n1 => w.record;\n3::second => now;\n\n\/\/ everything in between\n\n\n0 => w.record;\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"b7266fe51d18a166986e4f41e0ca977e77137e0b","subject":"local chuck","message":"local chuck\n","repos":"abramhindle\/abrams-chuck-snippets,abramhindle\/abrams-chuck-snippets,abramhindle\/abrams-chuck-snippets","old_file":"simple.ck","new_file":"simple.ck","new_contents":"Step s => dac;\n1 => int t => int t16 => int t20 => int x => int y => s.next;\n1024 => int m;\n1.0*m => float mm;\n1 => x;\nwhile( true ) {\n \/\/t>>6 => x;\n \/\/t ^ (t>>5 | t*t>>7 | 127&t*t>>10 | 6 *(t+3)) =>x;\n \/\/(t%8)&(t * 4 | t * 16 | (t+3)*7) => x;\n \/\/1 => y;\n \/\/8&t16*t20>>12 | (t<<7 % 2)^(127&t>>3) |(t<<6 % 2)^(127&t>>5) | (66&t>>2) => x;\n \/\/(t << 8)%2 *( x << 3 * ((y * 78) % 5)) => y;\n t& ((t*t << 9)%2 * t*t>>2 | t*2 | t>>5 | t>>3 | t*6 | t*t*19 | (127 & t * 62))=> x;\n \/\/-6*y*t16 => y;\/\/t*t16*(t * 3 | t * ((t<<5%2)+9) | t * 16) => y;\n \/\/(y * (y << 5)) * t => x;\n \/\/(1 + (((t>>7) | (t>>5)) | (63&(t16>>5)|(t*t>>3)))) => x;\n \/\/t16 ^ (1 + (((t<<8) | (t>>9)) | (63&(t16>>5)|(t*t>>3)))) => y;\n \/\/99&(t>>5) | 77 * t * t >> 3 => y;\n 199&t16*t*t>>13=>y;\n \/\/99&(t>>(((t<<5)%2) + 5)) | 77 * t * t >> 3 => y;\n x%m \/ mm - y%m\/mm => s.next;\n t + 1 => t;\n t%65536 => t16;\n t%1048576 => t20;\n 1::samp => now;\n}\n","old_contents":"Step s => dac;\n1 => int t => int t16 => int t20 => int x => int y => s.next;\n256 => int m;\n1.0*m => float mm;\n1 => x;\nwhile( true ) {\n t => x;\n 1 => y;\n x%m \/ mm - y%m\/mm => s.next;\n t + 1 => t;\n t%65536 => t16;\n t%1048576 => t20;\n 1::samp => now;\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"ChucK"} {"commit":"cd51cf5618fc49132812714c055af0c9b9b04a16","subject":"Added second data set","message":"Added second data set\n","repos":"DataOnAcid\/AudioRenderer,DataOnAcid\/AudioRenderer","old_file":"dataacid.ck","new_file":"dataacid.ck","new_contents":"\/*\nData on Acid hack\n\nIain Emsley\n\nSSI hack March 2015\n\n*\/\n\nFlute flute => Pan2 p => PoleZero f => JCRev r => dac;\n.8 => r.gain;\n.05 => r.mix;\n.99 => f.blockZero;\n\n.2 => float timeSt;\n\/\/recording\ndac => Gain g => WvOut w => blackhole;\n\n\/\/ print out all arguments\nme.arg(0) => string original;\nme.arg(1) => string copy;\nme.arg(2) => string outname;\n\nint texta[5000];\nint textb[5000];\nint size;\n\/\/create the array and push into a variable\nreadInts(original) @=> texta;\nreadInts(copy) @=> textb;\n\noutname => w.wavFilename;\n\n\/\/ any gain you want for the output\n.5 => g.gain;\n\n\/\/start recording\n1 => w.record;\n\nfor (0 => int i; i w.record;\n\n\/\/ temporary workaround to automatically close file on remove-shred\nnull @=> w;\n\n\/\/ play the note\n\/\/ play the note\nfun void play(Flute flute, int note, float velocity, Pan2 p, float textpan) {\n \/\/ start the note\n Std.mtof( note ) => flute.freq;\n velocity => flute.noteOn;\n .6 => flute.gain;\n textpan => p.pan;\n 100::ms => now;\n velocity => flute.noteOff;\n \n}\n\n\/\/ read the ints into an array\n\/\/ http:\/\/wiki.cs.princeton.edu\/index.php\/ChucK\/Dev\/IO\/FileIO\nfun int[] readInts(string path) {\n \n \/\/ open the file\n FileIO file;\n if (!file.open(path, FileIO.READ)) {\n <<< \"file read failed\" >>>;\n <<< path >>>;\n int ret[0]; \/\/ error opening the specified file\n return ret;\n }\n \n \/\/ read the size of the array\n file => size;\n \/\/ now read in the contents\n int ret[size];\n for (0 => int i; i < size; i++) \n file => ret[i];\n\n file.close(); \n return ret; \n}\n","old_contents":"\/*\nData on Acid hack\n\nIain Emsley\n\nSSI hack March 2015\n\n*\/\n\n\/\/SawOsc s => dac;\nFlute flute => PoleZero f => JCRev r => dac;\n.95 => r.gain;\n.05 => r.mix;\n.99 => f.blockZero;\n\n.2 => float timeSt;\n\/\/recording\ndac => Gain g => WvOut w => blackhole;\n\n\/\/ print out all arguments\nme.arg(0) => string inname;\nme.arg(1) => string outname;\n\nint drama[5000];\n\/\/create the array and push into a variable\nreadInts(inname) @=> drama;\n\noutname => w.wavFilename;\n\n\/\/ any gain you want for the output\n.5 => g.gain;\n\n\/\/start recording\n1 => w.record;\n\nfor (0 => int i; i w.record;\n\n\/\/ temporary workaround to automatically close file on remove-shred\nnull @=> w;\n\n\/\/ play the note\nfun void play(Flute flute, int note, float velocity) {\n \/\/ start the note\n Std.mtof( note ) => flute.freq;\n velocity => flute.noteOn;\n .6 => flute.gain;\n 100::ms => now;\n velocity => flute.noteOff;\n \/\/10::ms => now;\n}\n\n\/\/ read the ints into an array\n\/\/ http:\/\/wiki.cs.princeton.edu\/index.php\/ChucK\/Dev\/IO\/FileIO\nfun int[] readInts(string path) {\n \n \/\/ open the file\n FileIO file;\n if (!file.open(path, FileIO.READ)) {\n <<< \"file read failed\" >>>;\n <<< path >>>;\n int ret[0]; \/\/ error opening the specified file\n return ret;\n }\n \n \/\/ read the size of the array\n \/\/4096 => int size;\n file => int size;\n \/\/ now read in the contents\n int ret[size];\n for (0 => int i; i < size; i++) \n file => ret[i];\n\n file.close(); \n return ret; \n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"ChucK"} {"commit":"851910c73acf4f7195e556dbfa6f94d80b227b5d","subject":"More extensive threshold tests","message":"More extensive threshold tests\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"test\/threshold_test.ck","new_file":"test\/threshold_test.ck","new_contents":"<<< \">>> Testing Threshold class\", \"\" >>>;\n\n<<< \">>> Loading class\", \"\">>>;\nThreshold thr => dac;\nspork ~ thr.on();\n\n<<< \">>> Loading audio files\", \"\">>>;\nSndBuf buf;\nme.dir() + \"\/..\/sounds\/test_sound_01.wav\" => buf.read;\n1 => buf.loop;\n\n<<< \">>> Running test\", \"\">>>;\nbuf => thr;\n\n<<< \"\\n--- Current params:\", \"\">>>;\n<<< \"--- Level: \", \"0.75\">>>;\n0.75 => thr.set_threshold;\n10::second => now;\n\n<<< \"\\n--- Current params:\", \"\">>>;\n<<< \"--- Level: \", \"0.5\">>>;\n0.5 => thr.set_threshold;\n10::second => now;\n","old_contents":"<<< \">>> Testing Threshold class\", \"\" >>>;\n\n<<< \">>> Loading class\", \"\">>>;\nThreshold thr => dac;\n0.75 => thr.set_threshold;\nspork ~ thr.on();\n\n<<< \">>> Loading audio files\", \"\">>>;\nSndBuf buf_1;\nme.dir() + \"\/..\/sounds\/test_sound_01.wav\" => buf_1.read;\n\n\/\/ TODO change parameters to test if it works\n<<< \">>> Running test\", \"\">>>;\nbuf_1 => thr;\n10::second => now;\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"ChucK"} {"commit":"036b399f5b93fd46b57a670f5528622574b466d3","subject":"Stablized","message":"Stablized\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\",\"IIdim\",\"IIaug\",\"IIsus4\",\"II7\",\"ii7\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"iv\"],\n [\"bV\",\"bv\",\"bVdim\",\"bVaug\",\"bVsus4\",\"bV7\",\"bv7\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n if (type==6)\n {\n [root,root+3,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\nclass IntList\n{\n 0=>int size;\n IntNode @ first;\n IntNode @ last;\n \n fun void offer(int o)\n {\n IntNode n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun int poll()\n {\n if (size==0)\n return -1;\n size--;\n first @=> IntNode n;\n n.next @=> first;\n return n.object;\n }\n}\nclass IntNode\n{\n int object;\n IntNode @ next;\n fun void init(int o)\n {\n o=>object;\n }\n}\nclass LinkedList \/\/great pain to write a linked list in chuck\n{\n 0=>int size;\n Node @ first;\n Node @ last;\n \n fun void offer(Object o)\n {\n Node n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun Object poll()\n {\n if (size==0)\n return null;\n size--;\n first @=> Node n;\n n.next @=> first;\n return n.object;\n }\n fun Object add(Object o[])\n {\n for (0=>int i; iobject;\n }\n}\n\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord IIdim;\nChord ii7;\nChord iii;\nChord III;\nChord bv7;\nChord IV;\nChord iv;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi,ii7],[[0.1,0.1,0.1,0.3,0.2,0.1,0.1],[0.1,0.1,0.1,0.1,0.1,0.4,0.1]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[iii,III,V,vi],[[0.2,0.3,0.4,0.1],[0.4,0.3,0.2,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\nIIdim.init(2,2,[V],[[1.0],[1.0]]);\nii7.init(2,6,[I,V],[[0.3,0.7],[0.3,0.7]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi,iv],[[0.5,0.3,0.2],[0.2,0.6,0.2]]);\nIV.init(5,0,[I,V,V7,III,bv7],[[0.3,0.3,0.2,0.1,0.1],[0.2,0.4,0.1,0.2,0.1]]);\niv.init(5,1,[IV,V,vi],[[0.3,0.4,0.3],[0.2,0.4,0.4]]);\nbv7.init(6,6,[V],[[1.0],[1.0]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V,IIdim],[[0.2,0.2,0.1,0.3,0.1,0.1],[0.2,0.2,0.2,0.2,0.1,0.1]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI,ii],[[0.1,0.9],[0.1,0.9]]);\nIII.setModulation([[VIsus4]],[-3],[I]);\nI.setModulation([[VI],[I7],[VI]],[2,5,7],[I,I,V]);\nRhodey instruments[4];\nIntList beats;\nIntList keys;\nLinkedList chords;\nchords.offer(I);\nkeys.offer(3);\nbeats.offer(4);\n0=>int rhythmCounter;\nfun void generateChords()\n{\n chords.getLast() $ Chord @=> Chord lastChord;\n if (lastChord.getModulationSequence()!=null && Math.random2f(0, 1)<0.2)\n {\n lastChord.getModulationSequence()@=>Chord modSqs[][];\n lastChord.getModulationTarget()@=>int modKeys[];\n lastChord.getModulationChord()@=>Chord targetChords[];\n Math.random2f(0,modSqs.cap()) $ int =>int choice;\n modSqs[choice]@=>Chord modSq[];\n modKeys[choice]=>int keyChange;\n targetChords[choice]@=>Chord targetChord;\n for (0=>int i; i float p;\n if (p<=0.6)\n {\n beats.offer(4);\n }\n else if (p<=0.7)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(2);\n }\n else if (p<=0.8)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n }\n else if (p<=0.9)\n {\n beats.offer(6);\n beats.offer(2);\n }\n else\n {\n beats.offer(3);\n beats.offer(2);\n beats.offer(3);\n }\n}\n\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n\nfun void playChord(Chord current, int key, int beat)\n{\n if (beats.size==0)\n {\n generateBeats();\n }\n current.root=>int root;\n current.type=>int type;\n send.startMsg(\"\/key\/root\/type\", \"i i i\");\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n current.getNotesWithin()@=>int notes[];\n <<< \"Chord Name: \", current.toString() >>>;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n <<< \"Beats Played: \", beat>>>;\n for (0=>int j;jnow;\n float dyn;\n if (rhythmCounter == 0)\n 0.2=>dyn;\n else if (rhythmCounter == 2)\n 0.11=>dyn;\n else\n 0.07=>dyn;\n Std.mtof(36+(key+notes[0]%12))=>instruments[0].freq;\n dyn=>instruments[0].noteOn;\n for (1=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n dyn=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n dyn=>instruments[i].noteOn;\n }\n <<<\"beat: \", rhythmCounter>>>;\n (rhythmCounter+1)%4=>rhythmCounter;\n }\n}\nwhile (true)\n{\n if (chords.size<5)\n { \n generateChords();\n }\n if (beats.size<5)\n { \n generateBeats;\n }\n playChord(chords.poll()$Chord, keys.poll(), beats.poll());\n}\n\n\n","old_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\",\"IIdim\",\"IIaug\",\"IIsus4\",\"II7\",\"ii7\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"iv\"],\n [\"bV\",\"bv\",\"bVdim\",\"bVaug\",\"bVsus4\",\"bV7\",\"bv7\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n if (type==6)\n {\n [root,root+3,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\nclass IntList\n{\n 0=>int size;\n IntNode @ first;\n IntNode @ last;\n \n fun void offer(int o)\n {\n IntNode n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun int poll()\n {\n if (size==0)\n return -1;\n size--;\n first @=> IntNode n;\n n.next @=> first;\n return n.object;\n }\n}\nclass IntNode\n{\n int object;\n IntNode @ next;\n fun void init(int o)\n {\n o=>object;\n }\n}\nclass LinkedList \/\/great pain to write a linked list in chuck\n{\n 0=>int size;\n Node @ first;\n Node @ last;\n \n fun void offer(Object o)\n {\n Node n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun Object poll()\n {\n if (size==0)\n return null;\n size--;\n first @=> Node n;\n n.next @=> first;\n return n.object;\n }\n fun Object add(Object o[])\n {\n for (0=>int i; iobject;\n }\n}\n\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord IIdim;\nChord ii7;\nChord iii;\nChord III;\nChord bv7;\nChord IV;\nChord iv;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi,ii7],[[0.1,0.1,0.1,0.3,0.2,0.1,0.1],[0.1,0.1,0.1,0.1,0.1,0.4,0.1]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[iii,III,V,vi],[[0.2,0.3,0.4,0.1],[0.4,0.3,0.2,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\nIIdim.init(2,2,[V],[[1.0],[1.0]]);\nii7.init(2,6,[I,V],[[0.3,0.7],[0.3,0.7]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi,iv],[[0.5,0.3,0.2],[0.2,0.6,0.2]]);\nIV.init(5,0,[I,V,V7,III,bv7],[[0.3,0.3,0.2,0.1,0.1],[0.2,0.4,0.1,0.2,0.1]]);\niv.init(5,1,[IV,V,vi],[[0.3,0.4,0.3],[0.2,0.4,0.4]]);\nbv7.init(6,6,[V],[[1.0],[1.0]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V,IIdim],[[0.2,0.2,0.1,0.3,0.1,0.1],[0.2,0.2,0.2,0.2,0.1,0.1]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI],[[1.0],[1.0]]);\nIII.setModulation([[VIsus4]],[-3],[I]);\nI.setModulation([[VI],[I7],[VI]],[2,5,7],[I,I,V]);\nRhodey instruments[4];\nIntList beats;\nIntList keys;\nLinkedList chords;\nchords.offer(IV);\nkeys.offer(3);\nbeats.offer(4);\n0=>int rhythmCounter;\nfun void generateChords()\n{\n chords.getLast() $ Chord @=> Chord lastChord;\n if (lastChord.getModulationSequence()!=null && Math.random2f(0, 1)<0.2)\n {\n lastChord.getModulationSequence()@=>Chord modSqs[][];\n lastChord.getModulationTarget()@=>int modKeys[];\n lastChord.getModulationChord()@=>Chord targetChords[];\n Math.random2f(0,modSqs.cap()) $ int =>int choice;\n modSqs[choice]@=>Chord modSq[];\n modKeys[choice]=>int keyChange;\n targetChords[choice]@=>Chord targetChord;\n for (0=>int i; i float p;\n if (p<=0.6)\n {\n beats.offer(4);\n }\n else if (p<=0.7)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(2);\n }\n else if (p<=0.8)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n }\n else if (p<=0.9)\n {\n beats.offer(6);\n beats.offer(2);\n }\n else\n {\n beats.offer(3);\n beats.offer(2);\n beats.offer(3);\n }\n}\n\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n\nfun void playChord(Chord current, int key, int beat)\n{\n if (beats.size==0)\n {\n generateBeats();\n }\n current.root=>int root;\n current.type=>int type;\n send.startMsg(\"\/key\/root\/type\", \"i i i\");\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n current.getNotesWithin()@=>int notes[];\n <<< \"Chord Name: \", current.toString() >>>;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n <<< \"Beats Played: \", beat>>>;\n for (0=>int j;jnow;\n float dyn;\n if (rhythmCounter == 0)\n 0.2=>dyn;\n else if (rhythmCounter == 2)\n 0.11=>dyn;\n else\n 0.07=>dyn;\n Std.mtof(36+(key+notes[0]%12))=>instruments[0].freq;\n dyn=>instruments[0].noteOn;\n for (1=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n dyn=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n dyn=>instruments[i].noteOn;\n }\n <<<\"beat: \", rhythmCounter>>>;\n (rhythmCounter+1)%4=>rhythmCounter;\n }\n}\nwhile (true)\n{\n if (chords.size<5)\n { \n generateChords();\n }\n if (beats.size<5)\n { \n generateBeats;\n }\n playChord(chords.poll()$Chord, keys.poll(), beats.poll());\n}\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"40a53bc311ac7114e4258a0263066d5ec8947dcd","subject":"Update common_functions.ck","message":"Update common_functions.ck\n\njoin_int_array","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/common_functions.ck","new_file":"utility_functions\/common_functions.ck","new_contents":"\/\/ Machine.add(\"utilities.ck\");\n\n\/* \n definitions\n\n fun void repr_int_array(int arr[]){}\n fun void repr_string_array(string arr[]){}\n \n fun int random_from(int arr[]){}\n fun int inArray(int token, int arr[]){}\n fun int indexOfClosest(int ival, int arr[]){}\n fun int to_note(string str){}\n fun int[] join_int_arrays(int arr1[], int arr2[]){}\n fun int[] set_from(int arr[]){}\n fun int[] randomArray_from(int arr[], int length){}\n fun int[] range(int start, int end){}\n fun int[] narray(int start, int next, int up_to){}\n fun int[] expand_scale(int scale[], int start_stop[]){ \n fun int[][] stepify(string sequence_data[]){}\n \n fun float average(int arr[]){}\n \n fun string repr(int arr[]){}\n fun string repr(string arr[]){}\n fun string[] split(string arr, string token){}\n \n fun SndBuf load_sample(string wavname){}\n\n \n https:\/\/gist.github.com\/anonymous\/7206152\n \n*\/ \n\n\n\nfun string[] split_str(string str, string token){\n\n string collect[0];\n int pos;\n int pos2;\n while( str.find(token) >0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] join_int_arrays(int arr1[], int arr2[]){\n for(0 => int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] randomArray_from(int arr[], int length){\n \/\/ return new array of capacity length chosing elements from arr\n int generated_arr[0];\n for(0 => int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i Gain g => ADSR a => dac;\n SinOsc s2 => g;\n SinOsc s3 => g;\n SinOsc s4 => g;\n 1.0 => a.target;\n 1000::ms => a.attackTime;\n 0.5 => a.sustainLevel;\n 1000::ms => a.decayTime;\n 1000::ms => a.releaseTime;\n 0.25 => g.gain;\n Std.mtof(midinote) => s1.freq;\n 2*s1.freq() => s3.freq => s4.freq;\n <<< (\"Starting\", me.id(), \"For\", t\/1000, \"at\", s1.freq()) >>>;\n 1 => a.keyOn;\n for (0 => int i; i < t; i + 1 => i) {\n s1.freq() * Std.rand2f(0.999,1.001) => s1.freq;\n s1.freq() * Std.rand2f(1.001,1.003) => s2.freq;\n s3.freq() * Std.rand2f(0.999,1.001) => s3.freq;\n s3.freq() * Std.rand2f(1.001,1.003) => s4.freq;\n if (t - 1000 == i) {\n 1 => a.keyOff;\n <<< (\"Ending\", me.id()) >>>;\n }\n 1::ms => now;\n }\n}\n\n1.001 => float s1m;\n1.003 => float s3m;\n\nfun void lfun(SinOsc s1, SinOsc s2, SinOsc s3, SinOsc s4) {\n while(1::ms => now) {\n s1.freq() * Std.rand2f(2.0 - s1m,s1m) => s1.freq;\n s1.freq() * Std.rand2f(s1m,s3m) => s2.freq;\n s3.freq() * Std.rand2f(2.0 - s1m,s1m) => s3.freq;\n s3.freq() * Std.rand2f(s1m,s3m) => s4.freq;\n }\n}\n0 => int count;\nfunction void simpledrone(int midinote, int t) {\n SinOsc s1 => Gain g => ADSR a => dac;\n SinOsc s2 => g;\n SinOsc s3 => g;\n SinOsc s4 => g;\n 1.0 => a.target;\n 1000::ms => a.attackTime;\n 0.5 => a.sustainLevel;\n 1000::ms => a.decayTime;\n 1000::ms => a.releaseTime;\n count + 1 => count;\n \/\/0.25 => g.gain;\n 0.25 * 1.0\/count => g.gain;\n Std.mtof(midinote) => s1.freq;\n 2*s1.freq() => s3.freq => s4.freq;\n <<< (\"Starting\", me.id(), \"For\", t\/1000, \"at\", s1.freq()) >>>;\n 1 => a.keyOn;\n spork ~ lfun(s1,s2,s3,s4);\n t :: ms => now;\n 1 => a.keyOff;\n 1000 :: ms => now;\n count - 1 => count;\n}\n\n\n\nStd.rand2(30,65) => int midi;\nStd.rand2(1000,10000) => int t;\nspork ~ simpledrone(midi, t);\n\/\/10::second => now;\n\n\/\/for ( 0 => i; i < 64;\n\/\/Create an OscRecv object:\nOscRecv orec;\n\/\/Tell the OscRecv object the port:\n10000 => orec.port;\n\/\/Tell the OscRecv object to start listening for OSC messages on that port:\norec.listen();\n\n\nfunction void fourch(OscEvent fourchEvent) {\n while ( true ) {\n <<< \"waiting\" >>>;\n fourchEvent => now; \/\/wait for events to arrive.\n while( fourchEvent.nextMsg() != 0 ) {\n fourchEvent.getFloat() => float f1;\n fourchEvent.getFloat() => float f2;\n fourchEvent.getFloat() => float f3;\n fourchEvent.getFloat() => float f4;\n <<< (f1,f2,f3,f4) >>>;\n 1.0 + 0.25*(f3-64)\/64 => s1m;\n 1.0 + 0.25*(f4-64)\/64 => s3m;\n spork ~ simpledrone(f1 $ int, (f2*500) $ int);\n }\n }\n}\n\n\nfunction void multiPitchLength(OscEvent multiEvent) {\n while ( true ) {\n <<< \"waiting for multi\" >>>;\n multiEvent => now; \/\/wait for events to arrive.\n while( multiEvent.nextMsg() != 0 ) {\n <<< \"Got Multi\" >>>;\n multiEvent.getFloat() * 127 => float f1;\n multiEvent.getFloat() * 127 => float f2;\n <<< (f1,f2) >>>;\n if (count < 40) {\n spork ~ simpledrone(f1 $ int, (20+f2*500) $ int);\n 2::ms => now;\n } else {\n <<< \"TOO MUCH!\" >>>;\n 2::ms => now;\n }\n }\n }\n}\n\nfunction void multiRange(OscEvent multiEvent) {\n while ( true ) {\n <<< \"waiting for multi\" >>>;\n multiEvent => now; \/\/wait for events to arrive.\n while( multiEvent.nextMsg() != 0 ) {\n <<< \"Got Multi\" >>>;\n multiEvent.getFloat() * 127 => float f1;\n multiEvent.getFloat() * 127 => float f2;\n \/\/<<< (f1,f2) >>>;\n 1.0 + 0.25*(f1-64)\/64 => s1m;\n 1.0 + 0.25*(f2-64)\/64 => s3m;\n <<< (s1m,s3m) >>>;\n 2::ms => now;\n }\n }\n}\n\n\norec.event(\"\/mixer\/fourch, f, f, f, f\") @=> OscEvent fourchEvent;\nspork ~ fourch(fourchEvent);\norec.event(\"\/multi\/1, f, f\") @=> OscEvent multiEvent;\nspork ~ multiPitchLength(multiEvent);\norec.event(\"\/multi\/2, f, f\") @=> OscEvent multiEvent2;\nspork ~ multiRange(multiEvent2);\n\n\nwhile( true ) {\n 10000::ms => now;\n <<< \"sleeping\" >>>;\n}\n\n","old_contents":"\nfunction void drone(int midinote, int t) {\n SinOsc s1 => Gain g => ADSR a => dac;\n SinOsc s2 => g;\n SinOsc s3 => g;\n SinOsc s4 => g;\n 1.0 => a.target;\n 1000::ms => a.attackTime;\n 0.5 => a.sustainLevel;\n 1000::ms => a.decayTime;\n 1000::ms => a.releaseTime;\n 0.25 => g.gain;\n Std.mtof(midinote) => s1.freq;\n 2*s1.freq() => s3.freq => s4.freq;\n <<< (\"Starting\", me.id(), \"For\", t\/1000, \"at\", s1.freq()) >>>;\n 1 => a.keyOn;\n for (0 => int i; i < t; i + 1 => i) {\n s1.freq() * Std.rand2f(0.999,1.001) => s1.freq;\n s1.freq() * Std.rand2f(1.001,1.003) => s2.freq;\n s3.freq() * Std.rand2f(0.999,1.001) => s3.freq;\n s3.freq() * Std.rand2f(1.001,1.003) => s4.freq;\n if (t - 1000 == i) {\n 1 => a.keyOff;\n <<< (\"Ending\", me.id()) >>>;\n }\n 1::ms => now;\n }\n}\n\n1.001 => float s1m;\n1.003 => float s3m;\n\nfun void lfun(SinOsc s1, SinOsc s2, SinOsc s3, SinOsc s4) {\n while(1::ms => now) {\n s1.freq() * Std.rand2f(2.0 - s1m,s1m) => s1.freq;\n s1.freq() * Std.rand2f(s1m,s3m) => s2.freq;\n s3.freq() * Std.rand2f(2.0 - s1m,s1m) => s3.freq;\n s3.freq() * Std.rand2f(s1m,s3m) => s4.freq;\n }\n}\n0 => int count;\nfunction void simpledrone(int midinote, int t) {\n SinOsc s1 => Gain g => ADSR a => dac;\n SinOsc s2 => g;\n SinOsc s3 => g;\n SinOsc s4 => g;\n 1.0 => a.target;\n 1000::ms => a.attackTime;\n 0.5 => a.sustainLevel;\n 1000::ms => a.decayTime;\n 1000::ms => a.releaseTime;\n count + 1 => count;\n \/\/0.25 => g.gain;\n 0.25 * 1.0\/count => g.gain;\n Std.mtof(midinote) => s1.freq;\n 2*s1.freq() => s3.freq => s4.freq;\n <<< (\"Starting\", me.id(), \"For\", t\/1000, \"at\", s1.freq()) >>>;\n 1 => a.keyOn;\n spork ~ lfun(s1,s2,s3,s4);\n t :: ms => now;\n 1 => a.keyOff;\n 1000 :: ms => now;\n count - 1 => count;\n}\n\n\n\nStd.rand2(30,65) => int midi;\nStd.rand2(1000,10000) => int t;\nspork ~ simpledrone(midi, t);\n\/\/10::second => now;\n\n\/\/for ( 0 => i; i < 64;\n\/\/Create an OscRecv object:\nOscRecv orec;\n\/\/Tell the OscRecv object the port:\n10000 => orec.port;\n\/\/Tell the OscRecv object to start listening for OSC messages on that port:\norec.listen();\n\norec.event(\"\/mixer\/fourch, f, f, f, f\") @=> OscEvent fourchEvent;\n\nwhile ( true ) {\n <<< \"waiting\" >>>;\n fourchEvent => now; \/\/wait for events to arrive.\n while( fourchEvent.nextMsg() != 0 ) {\n fourchEvent.getFloat() => float f1;\n fourchEvent.getFloat() => float f2;\n fourchEvent.getFloat() => float f3;\n fourchEvent.getFloat() => float f4;\n <<< (f1,f2,f3,f4) >>>;\n 1.0 + 0.1*(f3-64)\/64 => s1m;\n 1.0 + 0.1*(f4-64)\/64 => s3m;\n spork ~ simpledrone(f1 $ int, (f2*500) $ int);\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"ChucK"} {"commit":"1cf750144487346c41b9b0ffd50c911784a8f8d2","subject":"debugged chordProgression","message":"debugged chordProgression\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\",\"IIdim\",\"IIaug\",\"IIsus4\",\"II7\",\"ii7\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"iv\"],\n [\"bV\",\"bv\",\"bVdim\",\"bVaug\",\"bVsus4\",\"bV7\",\"bv7\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n if (type==6)\n {\n [root,root+3,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\nclass IntList\n{\n 0=>int size;\n IntNode @ first;\n IntNode @ last;\n \n fun void offer(int o)\n {\n IntNode n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun int poll()\n {\n if (size==0)\n return -1;\n size--;\n first @=> IntNode n;\n n.next @=> first;\n return n.object;\n }\n}\nclass IntNode\n{\n int object;\n IntNode @ next;\n fun void init(int o)\n {\n o=>object;\n }\n}\nclass LinkedList \/\/great pain to write a linked list in chuck\n{\n 0=>int size;\n Node @ first;\n Node @ last;\n \n fun void offer(Object o)\n {\n Node n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun Object poll()\n {\n if (size==0)\n return null;\n size--;\n first @=> Node n;\n n.next @=> first;\n return n.object;\n }\n fun Object add(Object o[])\n {\n for (0=>int i; iobject;\n }\n}\n\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord IIdim;\nChord ii7;\nChord iii;\nChord III;\nChord bv7;\nChord IV;\nChord iv;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi,ii7],[[0.1,0.1,0.1,0.3,0.2,0.1,0.1],[0.1,0.1,0.1,0.1,0.1,0.4,0.1]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[iii,III,V,vi],[[0.2,0.3,0.4,0.1],[0.4,0.3,0.2,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\nIIdim.init(2,2,[V],[[1.0],[1.0]]);\nii7.init(2,6,[I,V],[[0.3,0.7],[0.3,0.7]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi,iv],[[0.5,0.3,0.2],[0.2,0.6,0.2]]);\nIV.init(5,0,[I,V,V7,III,bv7],[[0.3,0.3,0.2,0.1,0.1],[0.2,0.4,0.1,0.2,0.1]]);\niv.init(5,1,[IV,V,vi],[[0.3,0.4,0.3],[0.2,0.4,0.4]]);\nbv7.init(6,6,[V],[[1.0],[1.0]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V,IIdim],[[0.2,0.2,0.1,0.3,0.1,0.1],[0.2,0.2,0.2,0.2,0.1,0.1]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI],[[1.0],[1.0]]);\nIII.setModulation([[VIsus4]],[-3],[I]);\nI.setModulation([[VI],[I7],[VI]],[2,5,7],[I,I,V]);\nRhodey instruments[4];\nIntList beats;\nIntList keys;\nLinkedList chords;\nchords.offer(IV);\nkeys.offer(3);\nbeats.offer(4);\n0=>int rhythmCounter;\nfun void generateChords()\n{\n chords.getLast() $ Chord @=> Chord lastChord;\n if (lastChord.getModulationSequence()!=null && Math.random2f(0, 1)<0.2)\n {\n lastChord.getModulationSequence()@=>Chord modSqs[][];\n lastChord.getModulationTarget()@=>int modKeys[];\n lastChord.getModulationChord()@=>Chord targetChords[];\n Math.random2f(0,modSqs.cap()) $ int =>int choice;\n modSqs[choice]@=>Chord modSq[];\n modKeys[choice]=>int keyChange;\n targetChords[choice]@=>Chord targetChord;\n for (0=>int i; i float p;\n if (p<=0.6)\n {\n beats.offer(4);\n }\n else if (p<=0.7)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(2);\n }\n else if (p<=0.8)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n }\n else if (p<=0.9)\n {\n beats.offer(6);\n beats.offer(2);\n }\n else\n {\n beats.offer(3);\n beats.offer(2);\n beats.offer(3);\n }\n}\n\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n\nfun void playChord(Chord current, int key, int beat)\n{\n if (beats.size==0)\n {\n generateBeats();\n }\n current.root=>int root;\n current.type=>int type;\n send.startMsg(\"\/key\/root\/type\", \"i i i\");\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n current.getNotesWithin()@=>int notes[];\n <<< \"Chord Name: \", current.toString() >>>;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n <<< \"Beats Played: \", beat>>>;\n for (0=>int j;jnow;\n float dyn;\n if (rhythmCounter == 0)\n 0.2=>dyn;\n else if (rhythmCounter == 2)\n 0.11=>dyn;\n else\n 0.07=>dyn;\n Std.mtof(36+(key+notes[0]%12))=>instruments[0].freq;\n dyn=>instruments[0].noteOn;\n for (1=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n dyn=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n dyn=>instruments[i].noteOn;\n }\n <<<\"beat: \", rhythmCounter>>>;\n (rhythmCounter+1)%4=>rhythmCounter;\n }\n}\nwhile (true)\n{\n if (chords.size<5)\n { \n generateChords();\n }\n if (beats.size<5)\n { \n generateBeats;\n }\n playChord(chords.poll()$Chord, keys.poll(), beats.poll());\n}\n\n\n","old_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\",\"IIdim\",\"IIaug\",\"IIsus4\",\"II7\",\"ii7\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"iv\"],\n [\"bV\",\"bv\",\"bVdim\",\"bVaug\",\"bVsus4\",\"bV7\",\"bv7\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n if (type==6)\n {\n [root,root+3,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\nclass IntList\n{\n 0=>int size;\n IntNode @ first;\n IntNode @ last;\n \n fun void offer(int o)\n {\n IntNode n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun int poll()\n {\n if (size==0)\n return -1;\n size--;\n first @=> IntNode n;\n n.next @=> first;\n return n.object;\n }\n}\nclass IntNode\n{\n int object;\n IntNode @ next;\n fun void init(int o)\n {\n o=>object;\n }\n}\nclass LinkedList \/\/great pain to write a linked list in chuck\n{\n 0=>int size;\n Node @ first;\n Node @ last;\n \n fun void offer(Object o)\n {\n Node n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun Object poll()\n {\n if (size==0)\n return null;\n size--;\n first @=> Node n;\n n.next @=> first;\n return n.object;\n }\n fun Object add(Object o[])\n {\n for (0=>int i; iobject;\n }\n}\n\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord IIdim;\nChord ii7;\nChord iii;\nChord III;\nChord bv7;\nChord IV;\nChord iv;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi,ii7],[[0.1,0.1,0.1,0.3,0.2,0.1,0.1],[0.1,0.1,0.1,0.1,0.1,0.4,0.1]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[iii,III,V,vi],[[0.2,0.3,0.4,0.1],[0.4,0.3,0.2,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\nIIdim.init(2,2,[V],[[1.0],[1.0]]);\nii7.init(2,6,[I,V],[[0.3,0.7],[0.3,0.7]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi,iv],[[0.5,0.3,0.2],[0.2,0.6,0.2]]);\nIV.init(5,0,[I,V,V7,III,bv7],[[0.3,0.3,0.2,0.1,0.1],[0.2,0.4,0.1,0.2,0.1]]);\niv.init(5,1,[VI,V,vi],[[0.3,0.4,0.3],[0.2,0.4,0.4]]);\nbv7.init(6,6,[V],[[1.0],[1.0]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V,IIdim],[[0.2,0.2,0.1,0.3,0.1,0.1],[0.2,0.2,0.2,0.2,0.1,0.1]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI],[[1.0],[1.0]]);\nIII.setModulation([[VIsus4]],[-3],[I]);\nI.setModulation([[VI],[I7],[VI]],[2,5,7],[I,I,V]);\nRhodey instruments[4];\nIntList beats;\nIntList keys;\nLinkedList chords;\nchords.offer(IV);\nkeys.offer(3);\nbeats.offer(4);\n0=>int rhythmCounter;\nfun void generateChords()\n{\n chords.getLast() $ Chord @=> Chord lastChord;\n if (lastChord.getModulationSequence()!=null && Math.random2f(0, 1)<0.2)\n {\n lastChord.getModulationSequence()@=>Chord modSqs[][];\n lastChord.getModulationTarget()@=>int modKeys[];\n lastChord.getModulationChord()@=>Chord targetChords[];\n Math.random2f(0,modSqs.cap()) $ int =>int choice;\n modSqs[choice]@=>Chord modSq[];\n modKeys[choice]=>int keyChange;\n targetChords[choice]@=>Chord targetChord;\n for (0=>int i; i float p;\n if (p<=0.6)\n {\n beats.offer(4);\n }\n else if (p<=0.7)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(2);\n }\n else if (p<=0.8)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n }\n else if (p<=0.9)\n {\n beats.offer(6);\n beats.offer(2);\n }\n else\n {\n beats.offer(3);\n beats.offer(2);\n beats.offer(3);\n }\n}\n\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n\nfun void playChord(Chord current, int key, int beat)\n{\n if (beats.size==0)\n {\n generateBeats();\n }\n current.root=>int root;\n current.type=>int type;\n send.startMsg(\"\/key\/root\/type\", \"i i i\");\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n current.getNotesWithin()@=>int notes[];\n <<< \"Chord Name: \", current.toString() >>>;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n <<< \"Beats Played: \", beat>>>;\n for (0=>int j;jnow;\n float dyn;\n if (rhythmCounter == 0)\n 0.2=>dyn;\n else if (rhythmCounter == 2)\n 0.11=>dyn;\n else\n 0.07=>dyn;\n Std.mtof(36+(key+notes[0]%12))=>instruments[0].freq;\n dyn=>instruments[0].noteOn;\n for (1=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n dyn=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n dyn=>instruments[i].noteOn;\n }\n <<<\"beat: \", rhythmCounter>>>;\n (rhythmCounter+1)%4=>rhythmCounter;\n }\n}\nwhile (true)\n{\n if (chords.size<5)\n { \n generateChords();\n }\n if (beats.size<5)\n { \n generateBeats;\n }\n playChord(chords.poll()$Chord, keys.poll(), beats.poll());\n}\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"9f61c68e7aad229c1ef6f26e750452fad025f743","subject":"Slight changes","message":"Slight changes\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"class Chord\n{\n 0=>int style; \n Chord @ next[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities()@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return this;\n } \n fun float[] getProbabilities()\n {\n return getProbabilities(0);\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"vi\"],\n [\"bV\",\"bv\"],\n [\"V\",\"v\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n}\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord ii;\nChord iii;\nChord III;\nChord IV;\nChord V;\nChord vi;\nI.init(0,0,[I,ii,III,IV,V],[[0.1,0.1,0.1,0.4,0.3]]);\nii.init(2,1,[I,iii,III,V,vi],[[0.1,0.1,0.3,0.4,0.1]]);\niii.init(4,1,[V,IV,vi],[[0.2,0.4,0.4]]);\nIII.init(4,0,[IV,vi],[[0.4,0.6]]);\nIV.init(5,0,[I,V,III],[[0.3,0.6,0.1]]);\nV.init(7,0,[I,vi,ii],[[0.6,0.3,0.1]]);\nvi.init(9,1,[I,ii,iii,IV,V,vi],[[0.1,0.3,0.1,0.3,0.1,0.1]]);\nI @=> current;\nwhile (true)\n{\n <<< \"Chord Name: \", current.toString() >>>;\n 0=>int key;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNextChord()@=>current;\n 6::second=>now;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","old_contents":"\/* As you can see, this is a very raw Markov chain for chord progressions\n * It would be great if melodies can be generated according to this state machine\n * I use classes only because a ton of \"else if\" looks really messy, though the object-oriented of this language is really bad\n * The blank funcion is intended for future data receiving\n * It sends basic information of a chord\n * I hope melody can be generated according to the chord\n *\/\n \n\/\/the very basic chord base\nclass Chord\n{\n string name; \/\/how you call it\n string nextChord[]; \/\/next states\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probability[]; \/\/probability for each next state\n fun string getNextChordName() \/\/randomly choose the next chord\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n for (0=>int i; ic;\n if (rand<=c)\n return nextChord[i];\n }\n return this.name;\n }\n fun void setStyle(){} \/\/may be used to change probabilities\n}\n\nclass ChordMajor extends Chord\n{\n 0=>type;\n}\n\nclass ChordMinor extends Chord\n{\n 1=>type;\n}\n\nclass ChordI extends ChordMajor\n{\n \"I\"=>name;\n 0=>root;\n [\"I\", \"ii\",\"III\",\"IV\",\"V\"]@=>nextChord;\n [0.1,0.1,0.1,0.4,0.3]@=>probability;\n}\nclass Chordii extends ChordMinor\n{\n \"ii\"=>name;\n 2=>root;\n [\"I\",\"iii\",\"III\",\"V\",\"vi\"]@=>nextChord;\n [0.1,0.1,0.3,0.4,0.1]@=>probability;\n}\nclass Chordiii extends ChordMinor\n{\n \"iii\"=>name;\n 4=>root;\n [\"V\",\"IV\",\"vi\"]@=>nextChord;\n [0.2,0.4,0.4]@=>probability;\n}\nclass ChordIII extends ChordMajor\n{\n \"III\"=>name;\n 4=>root;\n [\"IV\",\"vi\"]@=>nextChord;\n [0.4,0.6]@=>probability;\n}\nclass ChordIV extends ChordMajor\n{\n \"IV\"=>name;\n 5=>root;\n [\"I\",\"V\",\"III\"]@=>nextChord;\n [0.3,0.6,0.1]@=>probability;\n}\nclass ChordV extends ChordMajor\n{\n \"V\"=>name;\n 7=>root;\n [\"I\",\"vi\",\"ii\"]@=>nextChord;\n [0.6,0.3,0.1]@=>probability;\n}class Chordvi extends ChordMinor\n{\n \"vi\"=>name;\n 9=>root;\n [\"I\",\"ii\",\"iii\",\"IV\",\"V\",\"vi\"]@=>nextChord;\n [0.1,0.3,0.1,0.3,0.1,0.1]@=>probability;\n}\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChordI I;\nChordii ii;\nChordiii iii;\nChordIII III;\nChordIV IV;\nChordV V;\nChordvi vi;\nfun Chord getChord(string s)\n{\n if (s==\"I\")\n return I;\n if (s==\"ii\")\n return ii;\n if (s==\"iii\")\n return iii;\n if (s==\"III\")\n return III;\n if (s==\"IV\")\n return IV;\n if (s==\"V\")\n return V;\n if (s==\"vi\")\n return vi;\n return null;\n}\nI @=> current;\nwhile (true)\n{\n <<< \"Chord Name: \", current.name >>>;\n 0=>int key;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n getChord(current.getNextChordName())@=>current;\n 6::second=>now;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"2a1a104e0a32ae9a9f9ea2ddd2cfef47b702cdf1","subject":"Test commit on a dev branch","message":"Test commit on a dev branch\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"main.ck","new_file":"main.ck","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"bsd-3-clause","lang":"ChucK"} {"commit":"b0837516f7de86d21658b286671654302e7cba6c","subject":"Remove temp file","message":"Remove temp file\n","repos":"0gajun\/mal,0gajun\/mal,joncol\/mal,foresterre\/mal,hterkelsen\/mal,hterkelsen\/mal,SawyerHood\/mal,DomBlack\/mal,foresterre\/mal,SawyerHood\/mal,DomBlack\/mal,SawyerHood\/mal,DomBlack\/mal,0gajun\/mal,SawyerHood\/mal,hterkelsen\/mal,0gajun\/mal,joncol\/mal,DomBlack\/mal,hterkelsen\/mal,0gajun\/mal,DomBlack\/mal,hterkelsen\/mal,hterkelsen\/mal,SawyerHood\/mal,SawyerHood\/mal,joncol\/mal,hterkelsen\/mal,SawyerHood\/mal,SawyerHood\/mal,foresterre\/mal,0gajun\/mal,0gajun\/mal,0gajun\/mal,0gajun\/mal,hterkelsen\/mal,foresterre\/mal,foresterre\/mal,DomBlack\/mal,DomBlack\/mal,0gajun\/mal,DomBlack\/mal,hterkelsen\/mal,hterkelsen\/mal,hterkelsen\/mal,DomBlack\/mal,hterkelsen\/mal,foresterre\/mal,DomBlack\/mal,foresterre\/mal,hterkelsen\/mal,SawyerHood\/mal,DomBlack\/mal,0gajun\/mal,foresterre\/mal,0gajun\/mal,foresterre\/mal,SawyerHood\/mal,0gajun\/mal,SawyerHood\/mal,foresterre\/mal,hterkelsen\/mal,0gajun\/mal,hterkelsen\/mal,DomBlack\/mal,SawyerHood\/mal,DomBlack\/mal,hterkelsen\/mal,0gajun\/mal,0gajun\/mal,DomBlack\/mal,DomBlack\/mal,0gajun\/mal,foresterre\/mal,DomBlack\/mal,hterkelsen\/mal,SawyerHood\/mal,DomBlack\/mal,SawyerHood\/mal,foresterre\/mal,foresterre\/mal,DomBlack\/mal,SawyerHood\/mal,DomBlack\/mal,0gajun\/mal,foresterre\/mal,foresterre\/mal,foresterre\/mal,SawyerHood\/mal,SawyerHood\/mal,DomBlack\/mal,0gajun\/mal,foresterre\/mal,0gajun\/mal,DomBlack\/mal,SawyerHood\/mal,hterkelsen\/mal,hterkelsen\/mal","old_file":"chuck\/types\/subr\/MalTimeMs.ck","new_file":"chuck\/types\/subr\/MalTimeMs.ck","new_contents":"public class MalTimeMs extends MalSubr\n{\n fun MalObject call(MalObject args[])\n {\n \/\/ HACK: Std.system returns the status code only...\n \"\/tmp\/chuck-date.\" + Std.rand2(1000,9999) => string temp_file;\n Std.system(\"date +%s%3N > \" + temp_file);\n\n FileIO f;\n f.open(temp_file, FileIO.READ);\n f => int timestamp;\n f.close();\n\n Std.system(\"rm \" + temp_file);\n\n return MalInt.create(timestamp);\n }\n}\n","old_contents":"public class MalTimeMs extends MalSubr\n{\n fun MalObject call(MalObject args[])\n {\n \/\/ HACK: Std.system returns the status code only...\n \"\/tmp\/chuck-date.\" + Std.rand2(1000,9999) => string temp_file;\n Std.system(\"date +%s%3N > \" + temp_file);\n\n FileIO f;\n f.open(temp_file, FileIO.READ);\n f => int timestamp;\n f.close();\n\n return MalInt.create(timestamp);\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"ChucK"} {"commit":"c5c4cd47c2de6e3339789d98ae8fe559cb638c5e","subject":"main comment","message":"main comment\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"main.ck","new_file":"main.ck","new_contents":"\/**\n * This is an example main.ck file. It way produced\n * as a main file to play my concerts, so everything\n * is working and tested. The problem with it and\n * the rest of classes is that ChucK supports\n * Mac OSX *much* better than other platforms\n * Linux is the least supported. This is why\n * SndBuf was used instead of LiSa. :shrug:\n * Some bugs and strange \"shortcuts\" can be\n * the ffect of that situation. At the moment\n * the main problem with Beta Vulgaris is:\n *\n * 1. Lack of perlin noise in ChucK. I use simple\n * applet written in Processing and sending\n * perlin noise control signal via OSC :sad:\n *\n * 2. MIDI can't handle two MIDI events at one time\n * It's horrible, so in future MIDI-to-OSC\n * interface will be produced in Processing or sth.\n *\n * Have fun!!\n *\/\n\n\/\/ midi communication\nMidiIn midi_in;\nMidiMsg midi_msg;\n\/\/ midi event\nMidiEvent midi_event;\n\n\/\/ keyboard communication\nKBHit kb;\n\/\/ keyboard event\nKeyEvent e;\n\n\/\/ osc receiver\n\/\/ all osc events in this code come from Processing applet\n\/\/ that produces 1Dimensional perlin noise\n\/\/ Maybe in future it will provide an interface to\n\/\/ malfunctioning MIDI control\nOscRecv osc_receiver;\n5601 => osc_receiver.port;\nosc_receiver.listen();\n\n\nLooper looper[Globals.NUM_OF_TRACKS];\nCutter cutter[Globals.NUM_OF_TRACKS];\nPanner panner[Globals.NUM_OF_TRACKS];\nThreshold threshold[Globals.NUM_OF_TRACKS];\nStammer stammer[Globals.NUM_OF_TRACKS];\nGainer gainer[Globals.NUM_OF_TRACKS];\nGain master[Globals.NUM_OF_TRACKS];\n\nGain left, right;\n\nfor(0 => int i; i < Globals.NUM_OF_TRACKS; ++i) {\n looper[i].play();\n looper[i] => Loader.load_sound_files;\n\n cutter[i].play();\n osc_receiver.event(\"\/f\" + (i+1) + \",f\") => panner[i].osc_event;\n panner[i].play();\n threshold[i].play();\n stammer[i].play();\n osc_receiver.event(\"\/f\" + (i+21) + \",f\") => gainer[i].osc_event;\n gainer[i].play();\n}\n\n\n{ \/\/ track 0\n \/\/ this code has to be reimplemented as a separate class!!\n looper[0].connect(stammer[0]);\n stammer[0].connect(master[0]);\n master[0] => dac;\n}\n{ \/\/ track 1\n looper[1].connect(master[1]);\n master[1] => dac;\n}\n{ \/\/ track 2\n looper[2].connect(master[2]);\n master[2] => dac;\n}\n{ \/\/ track 3\n \/\/ this code has to be reimplemented as a separate class!!\n looper[3].connect(cutter[3]);\n cutter[3].connect(threshold[3]);\n threshold[3].connect(gainer[3]);\n gainer[3].connect(master[3]);\n master[3] => panner[3].input();\n panner[3].connect(dac);\n}\n{ \/\/ track 4\n \/\/ this code has to be reimplemented as a separate class!!\n looper[4].connect(cutter[4]);\n cutter[4].connect(threshold[4]);\n threshold[4].connect(gainer[4]);\n gainer[4].connect(master[4]);\n master[4] => panner[4].input();\n panner[4].connect(dac);\n}\n{ \/\/ track 5\n \/\/ this code has to be reimplemented as a separate class!!\n Delay d1, d2, d3;\n\n 15005::ms => d1.max => d2.max => d3.max;\n 5::second => d1.delay;\n 10::second => d2.delay;\n 15::second => d3.delay;\n\n Cutter c1, c2, c3;\n 4.0 => c1.set_freq;\n 8.0 => c1.set_freq;\n 15.0 => c1.set_freq;\n c1.play();\n c2.play();\n c3.play();\n\n Gainer g1, g2, g3;\n osc_receiver.event(\"\/f\" + 11 + \",f\") => g1.osc_event;\n osc_receiver.event(\"\/f\" + 12 + \",f\") => g2.osc_event;\n osc_receiver.event(\"\/f\" + 13 + \",f\") => g3.osc_event;\n g1.play();\n g2.play();\n g3.play();\n\n Panner p1, p2, p3;\n osc_receiver.event(\"\/f\" + 14 + \",f\") => p1.osc_event;\n osc_receiver.event(\"\/f\" + 15 + \",f\") => p2.osc_event;\n osc_receiver.event(\"\/f\" + 16 + \",f\") => p3.osc_event;\n p1.play();\n p2.play();\n p3.play();\n\n\n looper[5].connect(cutter[5]);\n looper[5]._output => d1;\n d1 => c1.input();\n looper[5]._output => d2;\n d2 => c2.input();\n looper[5]._output => d3;\n d3 => c3.input();\n\n cutter[5].connect(gainer[5]);\n c1.connect(g1);\n c2.connect(g2);\n c3.connect(g3);\n\n gainer[5].connect(panner[5]);\n g1.connect(p1);\n g2.connect(p2);\n g3.connect(p3);\n\n \/\/ is it a bug that Pan2 goes mono\n \/\/ when connected to Gain?\n panner[5].connect_left(left);\n panner[5].connect_right(right);\n p1.connect_left(left);\n p1.connect_right(right);\n p2.connect_left(left);\n p2.connect_right(right);\n p3.connect_left(left);\n p3.connect_right(right);\n\n left => dac.left;\n right => dac.right;\n}\n\n\n\/\/ midi listener\nspork ~ midi_listener();\nspork ~ midi_handler(midi_event);\n\n\n\/\/ main time loop\nwhile(true) {\n 1::samp => now;\n}\n\n\n\n\/\/ these function are here, because they need\n\/\/ an acces to Beets and UGens on tracks\n\/\/ to be completely re-implemented\n\/\/ with event handlers inside classes\n\/\/ just like with OSC messages\n\/\/ possible solution is to write external MIDI-to-OSC\n\/\/ interface as ChucK handles MIDI really bad\nfun void midi_handler(MidiEvent e) {\n float first_track_gain_reminder;\n int first_track_mute;\n\n float last_track_gain_reminder;\n int last_track_mute;\n\n while(true) {\n show_state();\n\n \/\/ wait for the midi event to come\n e => now;\n\n (e.cc_number \/ 10) - 1 => int track_num;\n e.cc_number % 10 => int control_num;\n\n\n \/\/ first four controls have the same function\n \/\/ for all the tracs, so are handled by control_num\n\n \/\/ V O L U M E\n if(control_num == 1) {\n if(track_num == 0 && first_track_mute == 1) {\n Utils.map_midi(e.cc_value) => first_track_gain_reminder;\n continue;\n }\n if(track_num == 5) {\n if(last_track_mute == 1) {\n Utils.map_midi(e.cc_value) => last_track_gain_reminder;\n }\n else {\n Utils.map_midi(e.cc_value) => left.gain;\n Utils.map_midi(e.cc_value) => right.gain;\n }\n continue;\n }\n\n Utils.map_midi(e.cc_value) => master[track_num].gain;\n continue;\n }\n \/\/ M U T E\n if(control_num == 2) {\n if(track_num == 0) {\n if(e.cc_value == 127) {\n master[track_num].gain() => first_track_gain_reminder;\n 0.0 => master[track_num].gain;\n 1 => first_track_mute;\n }\n else {\n first_track_gain_reminder => master[track_num].gain;\n 0 => first_track_mute;\n }\n continue;\n }\n if(track_num == 5) {\n if(e.cc_value == 127) {\n left.gain() => last_track_gain_reminder;\n 0.0 => left.gain;\n 0.0 => right.gain;\n\n 1 => last_track_mute;\n }\n else {\n last_track_gain_reminder => left.gain;\n last_track_gain_reminder => right.gain;\n\n 0 => last_track_mute;\n }\n continue;\n }\n\n Utils.map_midi(e.cc_value) $ int => int mute;\n if(mute == 0) {\n looper[track_num].play();\n }\n else {\n looper[track_num].stop();\n }\n continue;\n }\n if(control_num == 3) {\n \/\/ nothing going on there\n continue;\n }\n \/\/ F I L E S E L E C T I O N\n if(control_num == 4) {\n Utils.map_midi(e.cc_value, 0.0, looper[track_num].length() - 1.01) => float index;\n index $ int => looper[track_num].current_file;\n continue;\n }\n \/\/ P L A Y B A C K R A T E\n if(control_num == 5) {\n Utils.map_midi(e.cc_value, -2.0, 2.0) => looper[track_num].set_speed;\n continue;\n }\n\n \/\/ the rest of controls have different functions\n \/\/ for each track, so they are handled by track_num\n \/\/ T R A C K 1\n \/\/ T R A C K 2\n \/\/ T R A C K 3\n if(track_num == 0 && control_num == 6) {\n Utils.map_midi(e.cc_value, 2.0, 9.0) => stammer[track_num].set_freq;\n continue;\n }\n if(track_num == 3 || track_num == 4) {\n if(control_num == 7) {\n Utils.map_midi(e.cc_value, 0.0, 1.0) => threshold[track_num].set_threshold;\n continue;\n }\n if(control_num == 8) {\n Utils.map_midi(e.cc_value, 2.0, 25.0) => cutter[track_num].set_freq;\n continue;\n }\n }\n }\n}\n\n\n\nfun void midi_listener() {\n if(!midi_in.open(1)) {\n <<< \">>>\", \"MIDI can't be open\" >>>;\n me.exit();\n }\n\n while(true) {\n midi_in => now;\n\n while(midi_in.recv(midi_msg)) {\n \/\/ get cc number\n midi_msg.data2 => midi_event.cc_number;\n \/\/ get cc value\n midi_msg.data3 => midi_event.cc_value;\n\n \/\/ uncomment it to see, what is actually going on with MIDI\n \/\/ <<< midi_event.cc_number, \"::\", midi_event.cc_value >>>;\n\n \/\/ broadcast new data\n midi_event.broadcast();\n }\n }\n}\n\nfun void show_state() {\n Utils.clear_screen();\n\n for(0 => int i; i < Globals.NUM_OF_TRACKS; ++i) {\n <<< \"Track\", (i+1) >>>;\n <<< looper[i].show_current_state() >>>;\n <<< \"-------------\", \"-----------\" >>>;\n }\n}\n","old_contents":"\/**\n * This is an example main.ck file. It way produced\n * as a main file to play my concerts, so everything\n * is working and tested. The problem with it and\n * the rest of classes is that ChucK supports\n * Mac OSX *much* better than other platforms\n * Linux is the least supported. This is why\n * SndBuf was used instead of LiSa. :shrug:\n * Some bugs and strange \"shortcuts\" can be\n * the ffect of that situation. At the moment\n * the main problem with Beta Vulgaris is:\n *\n * 1. Lack of perlin noise in ChucK. I use simple\n * applet written in Processing and sending\n * perlin noise control signal via OSC\n *\n * 2. MIDI can't handle two MIDI events at one time\n * It's horrible, so in future MIDI-to-OSC\n * interface will be produced in Processing or sth.\n *\n * Have fun!!\n *\/\n\n\/\/ midi communication\nMidiIn midi_in;\nMidiMsg midi_msg;\n\/\/ midi event\nMidiEvent midi_event;\n\n\/\/ keyboard communication\nKBHit kb;\n\/\/ keyboard event\nKeyEvent e;\n\n\/\/ osc receiver\n\/\/ all osc events in this code come from Processing applet\n\/\/ that produces 1Dimensional perlin noise\n\/\/ Maybe in future it will provide an interface to\n\/\/ malfunctioning MIDI control\nOscRecv osc_receiver;\n5601 => osc_receiver.port;\nosc_receiver.listen();\n\n\nLooper looper[Globals.NUM_OF_TRACKS];\nCutter cutter[Globals.NUM_OF_TRACKS];\nPanner panner[Globals.NUM_OF_TRACKS];\nThreshold threshold[Globals.NUM_OF_TRACKS];\nStammer stammer[Globals.NUM_OF_TRACKS];\nGainer gainer[Globals.NUM_OF_TRACKS];\nGain master[Globals.NUM_OF_TRACKS];\n\nGain left, right;\n\nfor(0 => int i; i < Globals.NUM_OF_TRACKS; ++i) {\n looper[i].play();\n looper[i] => Loader.load_sound_files;\n\n cutter[i].play();\n osc_receiver.event(\"\/f\" + (i+1) + \",f\") => panner[i].osc_event;\n panner[i].play();\n threshold[i].play();\n stammer[i].play();\n osc_receiver.event(\"\/f\" + (i+21) + \",f\") => gainer[i].osc_event;\n gainer[i].play();\n}\n\n\n{ \/\/ track 0\n \/\/ this code has to be reimplemented as a separate class!!\n looper[0].connect(stammer[0]);\n stammer[0].connect(master[0]);\n master[0] => dac;\n}\n{ \/\/ track 1\n looper[1].connect(master[1]);\n master[1] => dac;\n}\n{ \/\/ track 2\n looper[2].connect(master[2]);\n master[2] => dac;\n}\n{ \/\/ track 3\n \/\/ this code has to be reimplemented as a separate class!!\n looper[3].connect(cutter[3]);\n cutter[3].connect(threshold[3]);\n threshold[3].connect(gainer[3]);\n gainer[3].connect(master[3]);\n master[3] => panner[3].input();\n panner[3].connect(dac);\n}\n{ \/\/ track 4\n \/\/ this code has to be reimplemented as a separate class!!\n looper[4].connect(cutter[4]);\n cutter[4].connect(threshold[4]);\n threshold[4].connect(gainer[4]);\n gainer[4].connect(master[4]);\n master[4] => panner[4].input();\n panner[4].connect(dac);\n}\n{ \/\/ track 5\n \/\/ this code has to be reimplemented as a separate class!!\n Delay d1, d2, d3;\n\n 15005::ms => d1.max => d2.max => d3.max;\n 5::second => d1.delay;\n 10::second => d2.delay;\n 15::second => d3.delay;\n\n Cutter c1, c2, c3;\n 4.0 => c1.set_freq;\n 8.0 => c1.set_freq;\n 15.0 => c1.set_freq;\n c1.play();\n c2.play();\n c3.play();\n\n Gainer g1, g2, g3;\n osc_receiver.event(\"\/f\" + 11 + \",f\") => g1.osc_event;\n osc_receiver.event(\"\/f\" + 12 + \",f\") => g2.osc_event;\n osc_receiver.event(\"\/f\" + 13 + \",f\") => g3.osc_event;\n g1.play();\n g2.play();\n g3.play();\n\n Panner p1, p2, p3;\n osc_receiver.event(\"\/f\" + 14 + \",f\") => p1.osc_event;\n osc_receiver.event(\"\/f\" + 15 + \",f\") => p2.osc_event;\n osc_receiver.event(\"\/f\" + 16 + \",f\") => p3.osc_event;\n p1.play();\n p2.play();\n p3.play();\n\n\n looper[5].connect(cutter[5]);\n looper[5]._output => d1;\n d1 => c1.input();\n looper[5]._output => d2;\n d2 => c2.input();\n looper[5]._output => d3;\n d3 => c3.input();\n\n cutter[5].connect(gainer[5]);\n c1.connect(g1);\n c2.connect(g2);\n c3.connect(g3);\n\n gainer[5].connect(panner[5]);\n g1.connect(p1);\n g2.connect(p2);\n g3.connect(p3);\n\n \/\/ is it a bug that Pan2 goes mono\n \/\/ when connected to Gain?\n panner[5].connect_left(left);\n panner[5].connect_right(right);\n p1.connect_left(left);\n p1.connect_right(right);\n p2.connect_left(left);\n p2.connect_right(right);\n p3.connect_left(left);\n p3.connect_right(right);\n\n left => dac.left;\n right => dac.right;\n}\n\n\n\/\/ midi listener\nspork ~ midi_listener();\nspork ~ midi_handler(midi_event);\n\n\n\/\/ main time loop\nwhile(true) {\n 1::samp => now;\n}\n\n\n\n\/\/ these function are here, because they need\n\/\/ an acces to Beets and UGens on tracks\n\/\/ to be completely re-implemented\n\/\/ with event handlers inside classes\n\/\/ just like with OSC messages\n\/\/ possible solution is to write external MIDI-to-OSC\n\/\/ interface as ChucK handles MIDI really bad\nfun void midi_handler(MidiEvent e) {\n float first_track_gain_reminder;\n int first_track_mute;\n\n float last_track_gain_reminder;\n int last_track_mute;\n\n while(true) {\n show_state();\n\n \/\/ wait for the midi event to come\n e => now;\n\n (e.cc_number \/ 10) - 1 => int track_num;\n e.cc_number % 10 => int control_num;\n\n\n \/\/ first four controls have the same function\n \/\/ for all the tracs, so are handled by control_num\n\n \/\/ V O L U M E\n if(control_num == 1) {\n if(track_num == 0 && first_track_mute == 1) {\n Utils.map_midi(e.cc_value) => first_track_gain_reminder;\n continue;\n }\n if(track_num == 5) {\n if(last_track_mute == 1) {\n Utils.map_midi(e.cc_value) => last_track_gain_reminder;\n }\n else {\n Utils.map_midi(e.cc_value) => left.gain;\n Utils.map_midi(e.cc_value) => right.gain;\n }\n continue;\n }\n\n Utils.map_midi(e.cc_value) => master[track_num].gain;\n continue;\n }\n \/\/ M U T E\n if(control_num == 2) {\n if(track_num == 0) {\n if(e.cc_value == 127) {\n master[track_num].gain() => first_track_gain_reminder;\n 0.0 => master[track_num].gain;\n 1 => first_track_mute;\n }\n else {\n first_track_gain_reminder => master[track_num].gain;\n 0 => first_track_mute;\n }\n continue;\n }\n if(track_num == 5) {\n if(e.cc_value == 127) {\n left.gain() => last_track_gain_reminder;\n 0.0 => left.gain;\n 0.0 => right.gain;\n\n 1 => last_track_mute;\n }\n else {\n last_track_gain_reminder => left.gain;\n last_track_gain_reminder => right.gain;\n\n 0 => last_track_mute;\n }\n continue;\n }\n\n Utils.map_midi(e.cc_value) $ int => int mute;\n if(mute == 0) {\n looper[track_num].play();\n }\n else {\n looper[track_num].stop();\n }\n continue;\n }\n if(control_num == 3) {\n \/\/ nothing going on there\n continue;\n }\n \/\/ F I L E S E L E C T I O N\n if(control_num == 4) {\n Utils.map_midi(e.cc_value, 0.0, looper[track_num].length() - 1.01) => float index;\n index $ int => looper[track_num].current_file;\n continue;\n }\n \/\/ P L A Y B A C K R A T E\n if(control_num == 5) {\n Utils.map_midi(e.cc_value, -2.0, 2.0) => looper[track_num].set_speed;\n continue;\n }\n\n \/\/ the rest of controls have different functions\n \/\/ for each track, so they are handled by track_num\n \/\/ T R A C K 1\n \/\/ T R A C K 2\n \/\/ T R A C K 3\n if(track_num == 0 && control_num == 6) {\n Utils.map_midi(e.cc_value, 2.0, 9.0) => stammer[track_num].set_freq;\n continue;\n }\n if(track_num == 3 || track_num == 4) {\n if(control_num == 7) {\n Utils.map_midi(e.cc_value, 0.0, 1.0) => threshold[track_num].set_threshold;\n continue;\n }\n if(control_num == 8) {\n Utils.map_midi(e.cc_value, 2.0, 25.0) => cutter[track_num].set_freq;\n continue;\n }\n }\n }\n}\n\n\n\nfun void midi_listener() {\n if(!midi_in.open(1)) {\n <<< \">>>\", \"MIDI can't be open\" >>>;\n me.exit();\n }\n\n while(true) {\n midi_in => now;\n\n while(midi_in.recv(midi_msg)) {\n \/\/ get cc number\n midi_msg.data2 => midi_event.cc_number;\n \/\/ get cc value\n midi_msg.data3 => midi_event.cc_value;\n\n \/\/ uncomment it to see, what is actually going on with MIDI\n \/\/ <<< midi_event.cc_number, \"::\", midi_event.cc_value >>>;\n\n \/\/ broadcast new data\n midi_event.broadcast();\n }\n }\n}\n\nfun void show_state() {\n Utils.clear_screen();\n\n for(0 => int i; i < Globals.NUM_OF_TRACKS; ++i) {\n <<< \"Track\", (i+1) >>>;\n <<< looper[i].show_current_state() >>>;\n <<< \"-------------\", \"-----------\" >>>;\n }\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"ChucK"} {"commit":"f3a370bf9b3708c9b123db492c86b0f9242c28e2","subject":"vital one note change","message":"vital one note change\n","repos":"zeffii\/ChucKScripts","old_file":"demo_files\/chuck_rider\/score.ck","new_file":"demo_files\/chuck_rider\/score.ck","new_contents":"PolySynth polysynBass;\nPolySynth polysynArp;\nPolySynth polysynLead;\nModCarp carper;\n\ncarper.out => dac;\n\nNRev reverb_bass[2];\nreverb_bass[0].mix(0.009);\nreverb_bass[1].mix(0.009);\npolysynBass.out.gain(3.2);\npolysynBass.out.left => DelayA bassD => reverb_bass[0] => dac.left;\npolysynBass.out.right => reverb_bass[1] => dac.right;\n123::samp => bassD.delay => bassD.max;\n\nNRev reverb_arp[2];\nreverb_arp[0].mix(0.04);\nreverb_arp[1].mix(0.04);\npolysynArp.out.gain(.41);\npolysynArp.out.left => reverb_arp[0] => dac.left;\npolysynArp.out.right => DelayA arpD => reverb_arp[1] => dac.right;\n43::samp => arpD.delay => arpD.max;\n\nNRev reverb_lead[2];\nreverb_lead[0].mix(0.11);\nreverb_lead[1].mix(0.11);\npolysynLead.out.gain(.21);\nreverb_lead[0].gain(0.16);\nreverb_lead[1].gain(0.16);\npolysynLead.out => Mix2 leadgain => dac;\nleadgain.gain(1.81);\nChorus pads[2];\npolysynLead.out.left => pads[0] => reverb_lead[0] => dac.left;\npolysynLead.out.right => pads[1] => DelayA leadD => reverb_lead[1] => dac.right;\n\n\n143::samp => leadD.delay => leadD.max;\n\nfor(0 => int i; i int pseq[];\n\n[0, 52, 54, 55] @=> int arp_1_notes[];\n[0, 50, 52, 53] @=> int arp_2_notes[];\n\n[2,0,3,2,2,3,2,2,3,2,2,2,1,2,2,3,2,0,3,2,2,3,2,2,3,2,2,2,1,2,2] @=> int arp_1_triggers[];\n\n[42, 40, 43] @=> int bass_notes[];\n\n\/\/ this is mighty ugly, but it allows each note to have a unique decay length.\n[[54, 500], [0, 0], [55, 300], [54, 300], [61, 2300], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[66, 600], [0, 0], [67, 500], [66, 200], [61, 3100], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[54, 350], [0, 0], [55, 300], [54, 360], [61, 370], [0, 0], [66, 300], [0, 0], [64, 5300]\n] @=> int lead_notes_1[][];\n\n\n[[54, 500], [0, 0], [55, 300], [54, 300], [61, 2300], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[66, 600], [0, 0], [67, 500], [66, 200], [61, 3100], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[54, 350], [0, 0], [55, 300], [54, 360], [61, 370], [0, 0], [66, 300], [0, 0], [67, 5300]\n] @=> int lead_notes_2[][];\n\n\n\/\/ INTRO\nrepeat(1){\n\n polysynArp.set_envelopes(2, 217, 2, 1410);\n\n spork ~ play_lead(lead_notes_1);\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[0], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_arp(arp_2_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[1], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_lead(lead_notes_2);\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[0], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[2], pseq, 0, 32);\n advance_time(32);\n\n}\n\nfun int to_int(float input){\n input $ int => int output;\n return output;\n}\n\n\n\/\/ lead\nfun void play_lead(int sequence[][]){\n\n int tnote;\n for(0 => int i; i int tval;\n if (tval > 0) {\n tval + 12 => tnote;\n sequence[i][1] => int decay;\n polysynLead.set_envelopes(42, decay, 22, to_int(decay*1.3));\n polysynLead.play_synth([tnote, tnote], 7500.0, 2.9, 2.1);\n }\n\n advance_time();\n }\n advance_time(25);\n}\n\nfun void play_bassline(int note, int triggers[], int start, int end){\n \/\/ extra insurance\n if (end > triggers.cap()) triggers.cap() => end;\n \n for(start => int i; i int i; i int trigval;\n if (trigval > 0) {\n notes[trigval] + 12 => int note_val;\n (notes[trigval] * 90) => float filter_from_freq;\n polysynArp.play_synth([note_val,note_val], filter_from_freq+1100.0, 5.2, 2.4);\n carper.play(note_val, 0.5, 2, 140);\n }\n advance_time();\n }\n}\n\n\/\/ overloading, careful.\nfun void advance_time(int num_units){\n (0.13::second * num_units) => now;\n}\nfun void advance_time(){\n 0.13::second => now;\n}\n\n\/\/ gist -m ","old_contents":"PolySynth polysynBass;\nPolySynth polysynArp;\nPolySynth polysynLead;\nModCarp carper;\n\ncarper.out => dac;\n\nNRev reverb_bass[2];\nreverb_bass[0].mix(0.009);\nreverb_bass[1].mix(0.009);\npolysynBass.out.gain(3.2);\npolysynBass.out.left => DelayA bassD => reverb_bass[0] => dac.left;\npolysynBass.out.right => reverb_bass[1] => dac.right;\n123::samp => bassD.delay => bassD.max;\n\nNRev reverb_arp[2];\nreverb_arp[0].mix(0.04);\nreverb_arp[1].mix(0.04);\npolysynArp.out.gain(.41);\npolysynArp.out.left => reverb_arp[0] => dac.left;\npolysynArp.out.right => DelayA arpD => reverb_arp[1] => dac.right;\n43::samp => arpD.delay => arpD.max;\n\nNRev reverb_lead[2];\nreverb_lead[0].mix(0.11);\nreverb_lead[1].mix(0.11);\npolysynLead.out.gain(.21);\nreverb_lead[0].gain(0.16);\nreverb_lead[1].gain(0.16);\npolysynLead.out => Mix2 leadgain => dac;\nleadgain.gain(1.81);\nChorus pads[2];\npolysynLead.out.left => pads[0] => reverb_lead[0] => dac.left;\npolysynLead.out.right => pads[1] => DelayA leadD => reverb_lead[1] => dac.right;\n\n\n143::samp => leadD.delay => leadD.max;\n\nfor(0 => int i; i int pseq[];\n\n[0, 52, 54, 55] @=> int arp_1_notes[];\n[0, 50, 52, 53] @=> int arp_2_notes[];\n\n[2,0,3,2,2,3,2,2,3,2,2,2,1,2,2,3,2,0,3,2,2,3,2,2,3,2,2,2,1,2,2] @=> int arp_1_triggers[];\n\n[42, 40, 43] @=> int bass_notes[];\n\n\/\/ this is mighty ugly, but it allows each note to have a unique decay length.\n[[54, 500], [0, 0], [55, 300], [54, 300], [61, 2300], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[66, 600], [0, 0], [64, 500], [66, 200], [61, 3100], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[54, 350], [0, 0], [55, 300], [54, 360], [61, 370], [0, 0], [66, 300], [0, 0], [64, 5300]\n] @=> int lead_notes_1[][];\n\n\n[[54, 500], [0, 0], [55, 300], [54, 300], [61, 2300], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[66, 600], [0, 0], [64, 500], [66, 200], [61, 3100], \n[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], \n[54, 350], [0, 0], [55, 300], [54, 360], [61, 370], [0, 0], [66, 300], [0, 0], [67, 5300]\n] @=> int lead_notes_2[][];\n\n\n\/\/ INTRO\nrepeat(1){\n\n polysynArp.set_envelopes(2, 217, 2, 1410);\n\n spork ~ play_lead(lead_notes_1);\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[0], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_arp(arp_2_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[1], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_lead(lead_notes_2);\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[0], pseq, 0, 32);\n advance_time(32);\n\n spork ~ play_arp(arp_1_notes, arp_1_triggers);\n spork ~ play_bassline(bass_notes[2], pseq, 0, 32);\n advance_time(32);\n\n}\n\nfun int to_int(float input){\n input $ int => int output;\n return output;\n}\n\n\n\/\/ lead\nfun void play_lead(int sequence[][]){\n\n int tnote;\n for(0 => int i; i int tval;\n if (tval > 0) {\n tval + 12 => tnote;\n sequence[i][1] => int decay;\n polysynLead.set_envelopes(42, decay, 22, to_int(decay*1.3));\n polysynLead.play_synth([tnote, tnote], 7500.0, 2.9, 2.1);\n }\n\n advance_time();\n }\n advance_time(25);\n}\n\nfun void play_bassline(int note, int triggers[], int start, int end){\n \/\/ extra insurance\n if (end > triggers.cap()) triggers.cap() => end;\n \n for(start => int i; i int i; i int trigval;\n if (trigval > 0) {\n notes[trigval] + 12 => int note_val;\n (notes[trigval] * 90) => float filter_from_freq;\n polysynArp.play_synth([note_val,note_val], filter_from_freq+1100.0, 5.2, 2.4);\n carper.play(note_val, 0.5, 2, 140);\n }\n advance_time();\n }\n}\n\n\/\/ overloading, careful.\nfun void advance_time(int num_units){\n (0.13::second * num_units) => now;\n}\nfun void advance_time(){\n 0.13::second => now;\n}\n\n\/\/ gist -m ","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"afeb40569e72a7919b42fb1600f1c7610e26d428","subject":"I still don't think this works.","message":"I still don't think this works.\n","repos":"jordanorelli\/wii-chuck-synth","old_file":"osc_recv.ck","new_file":"osc_recv.ck","new_contents":"OscRev recv;\n6449 => recv.port;\nrecv.listen();\n\n\n","old_contents":"","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"816306507a0b4334d28d946dda4b4864032b85e6","subject":"modified control","message":"modified control\n","repos":"gewang\/ofxChucK,gewang\/ofxChucK","old_file":"example_OculusDK2\/bin\/data\/ck\/turenas.ck","new_file":"example_OculusDK2\/bin\/data\/ck\/turenas.ck","new_contents":"\n\/\/ keyboard\nHid kb;\n\/\/ hid message\nHidMsg msg;\n\n\/\/ open\nif( !kb.openKeyboard(0) ) me.exit();\n<<< \"KB open:\", kb.name() >>>;\nspork ~ kbf();\n\n\/\/ patch\nSndBuf L => dac.left;\nSndBuf R => dac.right;\n\n\/\/ envelope followers\nL => OnePole envL => blackhole; L => envL; 3 => envL.op;\nR => OnePole envR => blackhole; R => envR; 3 => envR.op;\n.9995 => envL.pole => envR.pole;\n\n\/\/ load\nme.dir() + \"..\/audio\/turenas-L.aiff\" => L.read;\nme.dir() + \"..\/audio\/turenas-R.aiff\" => R.read;\nL.samples() => L.pos;\nR.samples() => R.pos;\n0 => L.gain => R.gain;\n\n-100 => float FRONT;\nFRONT * .5 => float FRONT_FENCE;\n100 => float BACK;\nBACK * .5 => float BACK_FENCE;\n\n\/\/ entities\nVREntity es[0];\nvec3 v;\npolar p;\ncomplex c;\nfun void makeOne()\n{\n \/\/ make a some points\n VR.makeEntity(\"one\"+es.size(),\"mesh\") @=> VREntity mesh;\n \/\/ make\n mesh.eval( \"vertex -1 -1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex 1 -1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex -1 1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex 1 1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n \/\/ draw as triangle\n mesh.eval( \"draw trianglestrip\" );\n \/\/ add to world\n VR.root().addChild( mesh );\n \/\/ loc\n Math.random2f(5,100) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => mesh.loc.x;\n c.im => mesh.loc.z;\n Math.random2f(FRONT,FRONT_FENCE) => mesh.loc.y;\n \n Math.random2f(.1,1) => mesh.rgba.r;\n Math.random2f(.1,1) => mesh.rgba.g;\n Math.random2f(.1,1) => mesh.rgba.b;\n Math.random2f(0,0) => mesh.rgba.a;\n Math.random2f(0,360) => mesh.ori.y;\n\n \/\/ add\n es << mesh;\n}\n\nVREntity @ es2[0];\nfloat es2t[0];\n\nfun void makeTwo()\n{\n \/\/ make a some points\n VR.makeEntity(\"two\"+es.size(),\"flare\") @=> VREntity f;\n \/\/ set the texture\n f.setString( \"texture\", \"texture:flare-1\");\n \/\/ loc\n Math.random2f(5,100) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => f.loc.x;\n c.im => f.loc.y;\n f.sca.setAll(10);\n Math.random2f(FRONT,FRONT_FENCE) => f.loc.z;\n \n Math.random2f(1,1) => f.rgba.r;\n Math.random2f(1,1) => f.rgba.g;\n Math.random2f(1,1) => f.rgba.b;\n Math.random2f(0,0) => f.rgba.a;\n \n \/\/ add\n es2 << f;\n es2t << Math.random2f(0,2*pi);\n\n \/\/ add to world\n VR.root().addChild( f );\n}\n\nVREntity @ es3[0];\nfloat es3t[0];\n\n-500 => float FRONT3;\nFRONT3 * .5 => float FRONT_FENCE3;\n300 => float BACK3;\nBACK3 * .5 => float BACK_FENCE3;\n\nfun void makeThree( float inner, float outer, float whereY, float varyY )\n{\n \/\/ make a some points\n VR.makeEntity(\"three\"+es.size(),\"mesh\") @=> VREntity f;\n \/\/ set the texture\n f.setString( \"texture\", \"texture:flare-1\");\n \n f.eval( \"draw points\" );\n repeat(4000)\n {\n \/\/ loc\n Math.random2f(inner,outer) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => v.x;\n Math.random2f(-1,1) => v.y;\n c.im => v.z;\n f.eval( \"vertex\", v );\n }\n \n 0 => f.loc.x;\n 0 => f.loc.z;\n Math.random2f(whereY,whereY*varyY) => f.loc.y;\n \n Math.random2f(1,1) => f.rgba.r;\n Math.random2f(1,1) => f.rgba.g;\n Math.random2f(1,1) => f.rgba.b;\n Math.random2f(0,0) => f.rgba.a;\n \n \/\/ add\n es3 << f;\n es3t << .0000002 \/ Math.pow((inner+outer)\/6.0\/outer,10);\n \/\/ <<< \"spin:\", es3t[es3t.size()-1] >>>;\n\n \/\/ add to world\n VR.root().addChild( f );\n}\n\n\n\/\/repeat(4)\n\/\/ for(int i; i < 10; i++ )\n\/\/ makeThree( 2*(20+i*15), 4*(20+i*15+5), FRONT3*3, .6 );\n\n\/\/repeat(4)\n\/\/ for(int i; i < 10; i++ )\n\/\/ makeThree( 2*(20+i*15), 4*(20+i*15+5), FRONT3*6, .6 );\n\n\/\/repeat(4)\n\/\/ for(int i; i < 10; i++ )\n\/\/ makeThree( 2*(20+i*15), 4*(20+i*15+5), FRONT3*12, .6 );\n\n\n\/\/ disable lights\nVR.allLightsOn();\n\n\/\/ bang detector\nfun void bangDetect()\n{\n while( true )\n {\n if( envL.last() > 0.0001 )\n {\n <<< \"BANG!!\", now\/second >>>;\n 100::ms => now;\n }\n 10::ms => now;\n }\n}\n\n\/\/ detector\n\/\/ spork ~ bangDetect();\nVREntity @ e;\n\n\/\/ loop\nwhile( true )\n{\n for( int i; i < es.size(); i++ )\n {\n es[i] @=> e;\n if( e.loc.y <= FRONT_FENCE )\n 1-Math.fabs((e.loc.y-FRONT_FENCE)\/(FRONT-FRONT_FENCE)) => e.rgba.a;\n else if( e.loc.y >= BACK_FENCE )\n 1-Math.fabs((e.loc.y-BACK_FENCE)\/(BACK-BACK_FENCE)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n \n if( e.rgba.a < 0 ) 0 => e.rgba.a;\n else if( e.rgba.a > 1 ) 1 => e.rgba.a;\n \n 5 +=> e.ori.y;\n .5 +=> e.loc.y;\n if( e.loc.y > BACK ) FRONT => e.loc.y;\n }\n \n for( int i; i < es2.size(); i++ )\n {\n es2[i] @=> e;\n if( e.loc.z <= FRONT_FENCE )\n 1-Math.fabs((e.loc.z-FRONT_FENCE)\/(FRONT-FRONT_FENCE)) => e.rgba.a;\n else if( e.loc.z >= BACK_FENCE )\n 1-Math.fabs((e.loc.z-BACK_FENCE)\/(BACK-BACK_FENCE)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n\n if( e.rgba.a < 0 ) 0 => e.rgba.a;\n else if( e.rgba.a > 1 ) 1 => e.rgba.a;\n \n Math.pow(envL.last(),1)*100 *=> e.rgba.a;\n\n 5 * (1 + .2*Math.sin(es2t[i])) => e.sca.setAll; .1 +=> es2t[i];\n .2 +=> e.loc.z;\n if( e.loc.z > BACK ) FRONT => e.loc.z;\n }\n \n for( int i; i < es3.size(); i++ )\n {\n es3[i] @=> e;\n if( e.loc.y <= FRONT_FENCE3 )\n 1-Math.fabs((e.loc.y-FRONT_FENCE3)\/(FRONT3-FRONT_FENCE3)) => e.rgba.a;\n else if( e.loc.y >= BACK_FENCE3 )\n 1-Math.fabs((e.loc.y-BACK_FENCE3)\/(BACK3-BACK_FENCE3)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n \n if( e.rgba.a < 0 ) 0 => e.rgba.a;\n else if( e.rgba.a > 1 ) 1 => e.rgba.a;\n \n es3t[i] +=> e.ori.y;\n .5 +=> e.loc.y;\n if( e.loc.y > BACK3 ) FRONT3 => e.loc.y;\n }\n \n \/\/ VR.root().rgba.setAll(Math.pow(envL.last(),.75)*500);\n \n \/\/ synch with display\n VR.displaySync() => now;\n}\n\nfun void kbf()\n{\n while( true )\n {\n \/\/ wait\n kb => now;\n \/\/ wait\n while( kb.recv(msg) )\n {\n if( !msg.isButtonDown() )\n continue;\n\n if( msg.ascii == 48 ) \/\/ 1\n {\n 0 => L.pos => R.pos;\n 1 => L.gain => R.gain;\n }\n \/\/ <<< \"kb:\", msg.ascii >>>;\n if( msg.ascii == 49 ) \/\/ 1\n {\n repeat(10) makeOne();\n }\n else if( msg.ascii == 50 ) \/\/ 2\n {\n repeat(10) makeTwo();\n }\n else if( msg.ascii == 51 ) \/\/ 3\n {\n for(int i; i < 10; i++ )\n makeThree( 2*(20+i*15), 4*(20+i*15+5), FRONT3*2.5, .75 );\n }\n }\n }\n}\n","old_contents":"\n\/\/ keyboard\nHid kb;\n\/\/ hid message\nHidMsg msg;\n\n\/\/ open\nif( !kb.openKeyboard(2) ) me.exit();\n<<< \"KB open:\", kb.name() >>>;\nspork ~ kbf();\n\n\/\/ patch\nSndBuf L => dac.left;\nSndBuf R => dac.right;\n\n\/\/ envelope followers\nL => OnePole envL => blackhole; L => envL; 3 => envL.op;\nR => OnePole envR => blackhole; R => envR; 3 => envR.op;\n.9995 => envL.pole => envR.pole;\n\n\/\/ load\nme.dir() + \"..\/audio\/turenas-L.aiff\" => L.read;\nme.dir() + \"..\/audio\/turenas-R.aiff\" => R.read;\n\n-100 => float FRONT;\nFRONT * .5 => float FRONT_FENCE;\n100 => float BACK;\nBACK * .5 => float BACK_FENCE;\n\n\/\/ entities\nVREntity es[0];\nvec3 v;\npolar p;\ncomplex c;\nfun void makeOne()\n{\n \/\/ make a some points\n VR.makeEntity(\"one\"+es.size(),\"mesh\") @=> VREntity mesh;\n \/\/ make\n mesh.eval( \"vertex -1 -1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex 1 -1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex -1 1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex 1 1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n \/\/ draw as triangle\n mesh.eval( \"draw trianglestrip\" );\n \/\/ add to world\n VR.root().addChild( mesh );\n \/\/ loc\n Math.random2f(5,100) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => mesh.loc.x;\n c.im => mesh.loc.z;\n Math.random2f(FRONT,FRONT_FENCE) => mesh.loc.y;\n \n Math.random2f(.1,1) => mesh.rgba.r;\n Math.random2f(.1,1) => mesh.rgba.g;\n Math.random2f(.1,1) => mesh.rgba.b;\n Math.random2f(0,0) => mesh.rgba.a;\n Math.random2f(0,360) => mesh.ori.y;\n\n \/\/ add\n es << mesh;\n}\n\nVREntity @ es2[0];\nfloat es2t[0];\n\nfun void makeTwo()\n{\n \/\/ make a some points\n VR.makeEntity(\"two\"+es.size(),\"flare\") @=> VREntity f;\n \/\/ set the texture\n f.setString( \"texture\", \"texture:flare-1\");\n \/\/ loc\n Math.random2f(5,100) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => f.loc.x;\n c.im => f.loc.y;\n f.sca.setAll(10);\n Math.random2f(FRONT,FRONT_FENCE) => f.loc.z;\n \n Math.random2f(1,1) => f.rgba.r;\n Math.random2f(1,1) => f.rgba.g;\n Math.random2f(1,1) => f.rgba.b;\n Math.random2f(0,0) => f.rgba.a;\n \n \/\/ add\n es2 << f;\n es2t << Math.random2f(0,2*pi);\n\n \/\/ add to world\n VR.root().addChild( f );\n}\n\nVREntity @ es3[0];\nfloat es3t[0];\n\n-500 => float FRONT3;\nFRONT3 * .5 => float FRONT_FENCE3;\n300 => float BACK3;\nBACK3 * .5 => float BACK_FENCE3;\n\nfun void makeThree( float inner, float outer )\n{\n \/\/ make a some points\n VR.makeEntity(\"three\"+es.size(),\"mesh\") @=> VREntity f;\n \/\/ set the texture\n f.setString( \"texture\", \"texture:flare-1\");\n \n f.eval( \"draw points\" );\n repeat(4000)\n {\n \/\/ loc\n Math.random2f(inner,outer) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => v.x;\n Math.random2f(-1,1) => v.y;\n c.im => v.z;\n f.eval( \"vertex\", v );\n }\n \n 0 => f.loc.x;\n 0 => f.loc.z;\n Math.random2f(FRONT3,FRONT_FENCE3) => f.loc.y;\n \n Math.random2f(1,1) => f.rgba.r;\n Math.random2f(1,1) => f.rgba.g;\n Math.random2f(1,1) => f.rgba.b;\n Math.random2f(0,0) => f.rgba.a;\n \n \/\/ add\n es3 << f;\n es3t << .0000002 \/ Math.pow((inner+outer)\/6.0\/outer,10);\n <<< \"spin:\", es3t[es3t.size()-1] >>>;\n\n \/\/ add to world\n VR.root().addChild( f );\n}\n\n\n\/\/ disable lights\nVR.allLightsOn();\n\n\/\/ bang detector\nfun void bangDetect()\n{\n while( true )\n {\n if( envL.last() > 0.0001 )\n {\n <<< \"BANG!!\", now\/second >>>;\n 100::ms => now;\n }\n 10::ms => now;\n }\n}\n\n\/\/ detector\n\/\/ spork ~ bangDetect();\nVREntity @ e;\n\n\/\/ loop\nwhile( true )\n{\n for( int i; i < es.size(); i++ )\n {\n es[i] @=> e;\n if( e.loc.y <= FRONT_FENCE )\n 1-Math.fabs((e.loc.y-FRONT_FENCE)\/(FRONT-FRONT_FENCE)) => e.rgba.a;\n else if( e.loc.y >= BACK_FENCE )\n 1-Math.fabs((e.loc.y-BACK_FENCE)\/(BACK-BACK_FENCE)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n 5 +=> e.ori.y;\n .5 +=> e.loc.y;\n if( e.loc.y > BACK ) FRONT => e.loc.y;\n }\n \n for( int i; i < es2.size(); i++ )\n {\n es2[i] @=> e;\n if( e.loc.z <= FRONT_FENCE )\n 1-Math.fabs((e.loc.z-FRONT_FENCE)\/(FRONT-FRONT_FENCE)) => e.rgba.a;\n else if( e.loc.z >= BACK_FENCE )\n 1-Math.fabs((e.loc.z-BACK_FENCE)\/(BACK-BACK_FENCE)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n\n Math.pow(envL.last(),1)*100 *=> e.rgba.a;\n\n 5 * (1 + .2*Math.sin(es2t[i])) => e.sca.setAll; .1 +=> es2t[i];\n .2 +=> e.loc.z;\n if( e.loc.z > BACK ) FRONT => e.loc.z;\n }\n \n for( int i; i < es3.size(); i++ )\n {\n es3[i] @=> e;\n if( e.loc.y <= FRONT_FENCE3 )\n 1-Math.fabs((e.loc.y-FRONT_FENCE3)\/(FRONT3-FRONT_FENCE3)) => e.rgba.a;\n else if( e.loc.y >= BACK_FENCE3 )\n 1-Math.fabs((e.loc.y-BACK_FENCE3)\/(BACK3-BACK_FENCE3)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n \n es3t[i] +=> e.ori.y;\n .5 +=> e.loc.y;\n if( e.loc.y > BACK3 ) FRONT3 => e.loc.y;\n }\n \n \/\/ VR.root().rgba.setAll(Math.pow(envL.last(),.75)*500);\n \n \/\/ synch with display\n VR.displaySync() => now;\n}\n\nfun void kbf()\n{\n while( true )\n {\n \/\/ wait\n kb => now;\n \/\/ wait\n while( kb.recv(msg) )\n {\n if( !msg.isButtonDown() )\n continue;\n\n \/\/ <<< \"kb:\", msg.ascii >>>;\n if( msg.ascii == 49 ) \/\/ 1\n {\n repeat(10) makeOne();\n }\n else if( msg.ascii == 50 ) \/\/ 2\n {\n repeat(10) makeTwo();\n }\n else if( msg.ascii == 51 ) \/\/ 3\n {\n for(int i; i < 10; i++ )\n makeThree( 2*(20+i*15), 4*(20+i*15+5) );\n }\n }\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"f66b432b8b515b36e6e6f02218953cc1f1cbc1cd","subject":"Update common_functions.ck","message":"Update common_functions.ck","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/common_functions.ck","new_file":"utility_functions\/common_functions.ck","new_contents":"\/\/ Machine.add(\"utilities.ck\");\n\n\/* \n definitions\n\n fun void repr_int_array(int arr[]){}\n fun void repr_string_array(string arr[]){}\n \n fun int random_from(int arr[]){}\n fun int inArray(int token, int arr[]){}\n fun int indexOfClosest(int ival, int arr[]){}\n fun int to_note(string str){}\n fun int[] join_int_arrays(int arr1[], int arr2[]){}\n fun int[] repeat_int_array(int arr[], int num_times){}\n fun int[] set_from(int arr[]){}\n fun int[] randomArray_from(int arr[], int length){}\n fun int[] range(int start, int end){}\n fun int[] narray(int start, int next, int up_to){}\n fun int[] expand_scale(int scale[], int start_stop[]){ \n fun int[][] stepify(string sequence_data[]){}\n \n fun float average(int arr[]){}\n \n fun string repr(int arr[]){}\n fun string repr(string arr[]){}\n fun string[] split(string arr, string token){}\n \n fun SndBuf load_sample(string wavname){}\n\n \n https:\/\/gist.github.com\/anonymous\/7206152\n \n*\/ \n\n\n\nfun string[] split_str(string str, string token){\n\n string collect[0];\n int pos;\n int pos2;\n while( str.find(token) >0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] join_int_arrays(int arr1[], int arr2[]){\n [arr1, arr2] @=> int arr[][];\n int new_arr[0];\n for(0 => int j; j int i; i int j; j int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -5 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] join_int_arrays(int arr1[], int arr2[]){\n [arr1, arr2] @=> int arr[][];\n int new_arr[0];\n for(0 => int j; j int i; i int j; j int i; i int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun int[] expand_scale(int scale[], int start_stop[]){\n\n \/\/ assumes we start somewhere above 0\n start_stop[0] => int start;\n start_stop[1] => int end;\n\n int expand_array[0];\n -1 => int last;\n int current;\n for(start => int i; i < end; i++){\n for(0 => int n; n current;\n if (!(current == last)){\n expand_array << current;\n current => last;\n }\n }\n }\n return expand_array;\n}\n\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_string_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n\nfun int[] set_from(int arr[]){\n \/\/ no order guaranteed\n \/\/ requires inArray() to be present.\n int new_arr[0];\n new_arr << arr[0];\n\n for(1 => int i; i\", \"?\",\n \"@\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\",\n \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\",\n \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\",\n \"X\", \"Y\", \"Z\", \"[\", \"\\\\\", \"]\", \"^\", \"_\",\n \"`\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\",\n \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\",\n \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\",\n \"x\", \"y\", \"z\", \"{\", \"|\", \"}\", \"~\", \"DEL\"] @=> string asciiTable[];\n\n chout <= prompt;\n chout.flush();\n\n while( !done )\n {\n kb => now;\n\n while( kb.more() && !done )\n {\n kb.getchar() => char;\n asciiTable[char] => repr;\n\n if( repr == \"EOT\" || repr == \"LF\" || repr == \"CR\" )\n {\n true => done;\n }\n else if( repr == \"DEL\" && Std.getenv(\"TERM\") != \"dumb\")\n {\n if( input.length() > 0)\n {\n chout <= \"\\033[1D\\033[0K\";\n chout.flush();\n input.substring(0, input.length()-1) => input;\n }\n }\n else\n {\n chout <= repr;\n chout.flush();\n repr +=> input;\n }\n }\n }\n\n chout <= \"\\n\";\n\n if( repr == \"EOT\" )\n {\n return null;\n }\n\n return input;\n }\n}\n\n","old_contents":"public class Readline\n{\n fun static string readline(string prompt)\n {\n int done;\n string input;\n KBHit kb;\n int char;\n string repr;\n\n [\"NUL\", \"SOH\", \"STX\", \"ETX\", \"EOT\", \"ENQ\", \"ACK\", \"BEL\",\n \"BS\", \"HT\", \"LF\", \"VT\", \"FF\", \"CR\", \"SO\", \"SI\",\n \"DLE\", \"DC1\", \"DC2\", \"DC3\", \"DC4\", \"NAK\", \"SYN\", \"ETB\",\n \"CAN\", \"EM\", \"SUB\", \"ESC\", \"FS\", \"GS\", \"RS\", \"US\",\n \" \", \"!\", \"\\\"\", \"#\", \"$\", \"%\", \"&\", \"'\",\n \"(\", \")\", \"*\", \"+\", \",\", \"-\", \".\", \"\/\",\n \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\",\n \"8\", \"9\", \":\", \";\", \"<\", \"=\", \">\", \"?\",\n \"@\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\",\n \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\",\n \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\",\n \"X\", \"Y\", \"Z\", \"[\", \"\\\\\", \"]\", \"^\", \"_\",\n \"`\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\",\n \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\",\n \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\",\n \"x\", \"y\", \"z\", \"{\", \"|\", \"}\", \"~\", \"DEL\"] @=> string asciiTable[];\n\n chout <= prompt;\n chout.flush();\n\n while( !done )\n {\n kb => now;\n\n while( kb.more() && !done )\n {\n kb.getchar() => char;\n asciiTable[char] => repr;\n\n if( repr == \"EOT\" || repr == \"LF\" || repr == \"CR\" )\n {\n true => done;\n }\n else\n {\n chout <= repr;\n chout.flush();\n repr +=> input;\n }\n }\n }\n\n chout <= \"\\n\";\n\n if( repr == \"EOT\" )\n {\n return null;\n }\n\n return input;\n }\n}\n\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"ChucK"} {"commit":"d94b5d4cac39caac22dca3ba88b79b4b03289a26","subject":"chordProgression change","message":"chordProgression change\n\nNow use queue to store chords.\n\/> chuck chordProgression to run\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"iv\"],\n [\"bV\",\"bv\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\nclass IntList\n{\n 0=>int size;\n IntNode @ first;\n IntNode @ last;\n \n fun void offer(int o)\n {\n IntNode n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun int poll()\n {\n if (size==0)\n return -1;\n size--;\n first @=> IntNode n;\n n.next @=> first;\n return n.object;\n }\n}\nclass IntNode\n{\n int object;\n IntNode @ next;\n fun void init(int o)\n {\n o=>object;\n }\n}\nclass LinkedList \/\/great pain to write a linked list in chuck\n{\n 0=>int size;\n Node @ first;\n Node @ last;\n \n fun void offer(Object o)\n {\n Node n;\n n.init(o);\n if (size==0)\n {\n n@=>first;\n n@=>last;\n }\n else\n {\n n@=>last.next;\n n@=>last;\n }\n size++;\n }\n fun Object poll()\n {\n if (size==0)\n return null;\n size--;\n first @=> Node n;\n n.next @=> first;\n return n.object;\n }\n fun Object add(Object o[])\n {\n for (0=>int i; iobject;\n }\n}\n\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord iii;\nChord III;\nChord IV;\nChord iv;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi],[[0.1,0.1,0.1,0.3,0.3,0.1],[0.1,0.1,0.1,0.1,0.1,0.5]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[iii,III,V,vi],[[0.2,0.3,0.4,0.1],[0.4,0.3,0.2,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi,iv],[[0.5,0.3,0.2],[0.2,0.6,0.2]]);\nIV.init(5,0,[I,V,V7,III],[[0.3,0.4,0.2,0.1],[0.2,0.4,0.1,0.3]]);\niv.init(5,1,[VI,V,vi],[[0.3,0.4,0.3],[0.2,0.4,0.4]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V],[[0.2,0.3,0.1,0.3,0.1],[0.2,0.2,0.2,0.2,0.2]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI],[[1.0],[1.0]]);\nIII.setModulation([[VIsus4]],[-3],[I]);\nI.setModulation([[VI],[I7],[VI]],[2,5,7],[I,I,V]);\nRhodey instruments[4];\nIntList beats;\nIntList keys;\nLinkedList chords;\nchords.offer(I);\nkeys.offer(3);\nbeats.offer(4);\n0=>int rhythmCounter;\nfun void generateChords()\n{\n chords.getLast() $ Chord @=> Chord lastChord;\n if (lastChord.getModulationSequence()!=null && Math.random2f(0, 1)<0.2)\n {\n lastChord.getModulationSequence()@=>Chord modSqs[][];\n lastChord.getModulationTarget()@=>int modKeys[];\n lastChord.getModulationChord()@=>Chord targetChords[];\n Math.random2f(0,modSqs.cap()) $ int =>int choice;\n modSqs[choice]@=>Chord modSq[];\n modKeys[choice]=>int keyChange;\n targetChords[choice]@=>Chord targetChord;\n for (0=>int i; i float p;\n if (p<=0.6)\n {\n beats.offer(4);\n }\n else if (p<=0.7)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(2);\n }\n else if (p<=0.8)\n {\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n beats.offer(3);\n }\n else if (p<=0.9)\n {\n beats.offer(6);\n beats.offer(2);\n }\n else\n {\n beats.offer(3);\n beats.offer(2);\n beats.offer(3);\n }\n}\n\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n\nfun void playChord(Chord current, int key, int beat)\n{\n if (beats.size==0)\n {\n generateBeats();\n }\n current.root=>int root;\n current.type=>int type;\n send.startMsg(\"\/key\/root\/type\", \"i i i\");\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n current.getNotesWithin()@=>int notes[];\n <<< \"Chord Name: \", current.toString() >>>;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n <<< \"Beats Played: \", beat>>>;\n for (0=>int j;jnow;\n float dyn;\n if (rhythmCounter == 0)\n 0.2=>dyn;\n else if (rhythmCounter == 2)\n 0.11=>dyn;\n else\n 0.07=>dyn;\n Std.mtof(36+(key+notes[0]%12))=>instruments[0].freq;\n dyn=>instruments[0].noteOn;\n for (1=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n dyn=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n dyn=>instruments[i].noteOn;\n }\n <<<\"beat: \", rhythmCounter>>>;\n (rhythmCounter+1)%4=>rhythmCounter;\n }\n}\nwhile (true)\n{\n if (chords.size<5)\n {\n generateChords();\n }\n if (beats.size<5)\n {\n generateBeats;\n }\n playChord(chords.poll()$Chord, keys.poll(), beats.poll());\n}\n\n\n","old_contents":"class Chord\n{\n 0=>static int mode;\n 0=>int style;\n Chord @ next[];\n int notes[];\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probabilities[][]; \/\/probability for each next state\n Chord @ modulationSequence[][];\n Chord @ modulationChord[];\n int modulationTarget[];\n fun void init(int root, int type, Chord next[], float probabilities[][])\n {\n setRoot(root);\n setType(type);\n setNext(next);\n setProbabilities(probabilities);\n setNotes();\n }\n fun void setRoot(int i)\n {\n i=>root;\n }\n fun void setType(int i)\n {\n i=>type;\n }\n fun void setNext(Chord c[])\n {\n c@=>next;\n }\n fun void setProbabilities(float f[][])\n {\n f@=>probabilities;\n }\n fun Chord getNextChord()\n {\n return getNextChord(mode);\n }\n fun Chord getNextChord(int i)\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n getProbabilities(i)@=>float p[];\n for (0=>int i; ic;\n if (rand<=c)\n return next[i];\n }\n return next[next.cap()-1];\n }\n fun float[] getProbabilities(int i)\n {\n return probabilities[i];\n }\n fun string toString()\n {\n [[\"I\",\"i\",\"Idim\",\"Iaug\",\"Isus4\",\"I7\"],\n [\"bII\",\"bii\"],\n [\"II\",\"ii\"],\n [\"bIII\",\"biii\"],\n [\"III\",\"iii\"],\n [\"IV\",\"vi\"],\n [\"bV\",\"bv\"],\n [\"V\",\"v\",\"Vdim\",\"Vaug\",\"Vsus4\",\"V7\"],\n [\"bVI\",\"bvi\"],\n [\"VI\",\"vi\",\"VIdim\",\"VIaug\",\"VIsus4\"],\n [\"bVII\",\"bvii\"],\n [\"VII\",\"vii\"]]@=>string s[][];\n return s[root][type];\n }\n fun void setNotes()\n {\n if (type==0)\n {\n [root,root+4,root+7]@=>notes;\n }\n if (type==1)\n {\n [root,root+3,root+7]@=>notes;\n }\n if (type==2)\n {\n [root,root+3,root+6]@=>notes;\n }\n if (type==3)\n {\n [root,root+4,root+8]@=>notes;\n }\n if (type==4)\n {\n [root,root+5,root+7]@=>notes;\n }\n if (type==5)\n {\n [root,root+4,root+7,root+10]@=>notes;\n }\n\n }\n fun int[] getNotesWithin()\n {\n return notes;\n }\n fun void setModulation(Chord modulation[][], int target[], Chord chord[])\n {\n modulation@=>modulationSequence;\n target@=>modulationTarget;\n chord@=>modulationChord;\n }\n fun Chord[][] getModulationSequence()\n {\n return modulationSequence;\n }\n fun int[] getModulationTarget()\n {\n return modulationTarget;\n }\n fun Chord[] getModulationChord()\n {\n return modulationChord;\n }\n}\n\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChord I;\nChord I7;\nChord ii;\nChord II;\nChord iii;\nChord III;\nChord IV;\nChord V;\nChord V7;\nChord vi;\nChord VI;\nChord Isus4;\nChord VIsus4;\nI.init(0,0,[I,ii,III,IV,V,vi],[[0.1,0.1,0.1,0.3,0.3,0.1],[0.1,0.1,0.1,0.1,0.1,0.5]]);\nI7.init(0,5,[I7],[[1.0],[1.0]]);\nii.init(2,1,[I,iii,III,V,vi],[[0.1,0.1,0.3,0.4,0.1],[0.1,0.4,0.3,0.1,0.1]]);\nII.init(2,0,[II],[[1.0],[1.0]]);\niii.init(4,1,[V,IV,vi],[[0.4,0.4,0.2],[0.2,0.3,0.5]]);\nIII.init(4,0,[IV,vi],[[0.6,0.4],[0.3,0.7]]);\nIV.init(5,0,[I,V,III],[[0.3,0.6,0.1],[0.2,0.5,0.3]]);\nV.init(7,0,[I,vi,ii,iii,Isus4,V7],[[0.2,0.2,0.1,0.2,0.1,0.2],[0.2,0.1,0.1,0.2,0.2,0.2]]);\nV7.init(7,5,[I,vi],[[0.8,0.2],[0.4,0.6]]);\nvi.init(9,1,[I,ii,iii,IV,V,vi],[[0.1,0.3,0.1,0.3,0.1,0.1],[0.1,0.2,0.2,0.2,0.2,0.1]]);\nIsus4.init(0,4,[I],[[1.0],[1.0]]);\nVIsus4.init(9,4,[vi],[[1.0],[1.0]]);\nVI.init(9,0,[VI],[[1.0],[1.0]]);\nIII.setModulation([[VIsus4,VI]],[-3],[I]);\nI.setModulation([[VI,II],[I7,IV]],[2,5],[I,I]);\nI @=> current;\nRhodey instruments[4];\nfor (0=>int i; i < instruments.cap(); i++)\n{\n instruments[i]=>dac;\n}\n0=>int key;\nwhile (true)\n{\n <<< \"Chord Name: \", current.toString() >>>;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNotesWithin()@=>int notes[];\n for (0=>int j;j<4;j++)\n {\n 0.5::second=>now;\n for (0=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n 0.2=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n 0.1=>instruments[i].noteOn;\n }\n }\n if (current.getModulationTarget()!=null&&Math.random2f(0,1)<0.9)\n {\n\n current.getModulationSequence()@=>Chord sq[][];\n current.getModulationTarget()@=>int keys[];\n current.getModulationChord()@=>Chord chords[];\n Math.random2f(0,sq.cap()) $ int =>int choice;\n sq[choice]@=>Chord chordSq[];\n keys[choice]=>int keyChange;\n chords[choice]@=>Chord modChord;\n for (0=>int i; i current;\n <<< \"Chord Name: \", current.toString() >>>;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n current.getNotesWithin()@=>int notes[];\n for (0=>int j;j<4;j++)\n {\n 0.5::second=>now;\n for (0=>int i; i < instruments.cap(); i++)\n {\n Std.mtof(48+(key+notes[i%notes.cap()])%12)=>instruments[i].freq;\n if (j==0)\n 0.2=>instruments[i].noteOn;\n else if (Math.random2f(0,1)<0.7)\n 0.1=>instruments[i].noteOn;\n }\n }\n }\n modChord.getNextChord()@=>current;\n (key+keyChange+12)%12=>key;\n }\n else\n {\n current.getNextChord()@=>current;\n }\n}\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"ChucK"} {"commit":"cc9a9b102f0e95dc289fcdb1c3c0cdb3562bf6da","subject":"Debug strings added","message":"Debug strings added\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"test\/stammer_test.ck","new_file":"test\/stammer_test.ck","new_contents":"<<< \"Testing Stammer class\" >>>;\n\n<<< \"Loading class\" >>>;\nStammer stm => dac;\n2.0 => stm.set_freq;\nspork ~ stm.local_loop();\n\n<<< \"Loading audio files\" >>>;\nSndBuf buf_1;\nSndBuf buf_2;\nme.dir() + \"\/..\/sounds\/test_sound_01.wav\" => buf_1.read;\nme.dir() + \"\/..\/sounds\/test_sound_02.wav\" => buf_2.read;\n\n<<< \"Running test\" >>>;\nbuf_2 => stm;\n10::second => now;\n\nbuf_2 =< stm;\nbuf_1 => stm;\n10::second => now;\n\nbuf_2 => stm;\n10::second => now;\n","old_contents":"Stammer stm => dac;\n2.0 => stm.set_freq;\nspork ~ stm.local_loop();\n\nSndBuf buf_1;\nSndBuf buf_2;\nme.dir() + \"\/..\/sounds\/test_sound_01.wav\" => buf_1.read;\nme.dir() + \"\/..\/sounds\/test_sound_02.wav\" => buf_2.read;\n\nbuf_2 => stm;\n10::second => now;\n\nbuf_2 =< stm;\nbuf_1 => stm;\n10::second => now;\n\nbuf_2 => stm;\n10::second => now;\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"ChucK"} {"commit":"91ebda26af581fa037b9e6edeba365ff907608ed","subject":"add chuck","message":"add chuck\n","repos":"pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds,pxlpnk\/xhelloworlds","old_file":"chuck\/hello.ck","new_file":"chuck\/hello.ck","new_contents":"\n\"monkey\" => string name;\n<<< \"hello \" + name >>>;","old_contents":"","returncode":1,"stderr":"error: pathspec 'chuck\/hello.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"ecdaee518f48bccfb540117f8b4fb7d2711cc42a","subject":"Create picking_oscillators.ck","message":"Create picking_oscillators.ck","repos":"zeffii\/ChucKScripts","old_file":"demo_files\/picking_oscillators.ck","new_file":"demo_files\/picking_oscillators.ck","new_contents":"\"sqr\" => string voiceType;\n\nOsc voiceOsc[1];\n\nif (voiceType == \"saw\") {new SawOsc @=> voiceOsc[0];}\nelse if (voiceType == \"sin\") {new SinOsc @=> voiceOsc[0];}\nelse if (voiceType == \"sqr\") {new SqrOsc @=> voiceOsc[0];}\n\nvoiceOsc[0].gain(0.5);\nvoiceOsc[0] => dac; \n\n2::second => now;\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'demo_files\/picking_oscillators.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"c4849c8888ca40852214c6644e1ef28487226fa0","subject":"added BKickONE class","message":"added BKickONE class\n\nthis might be a convenient way to write a percussion synth class,\nconvenience methods for patch setting and saving.\n","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/BKickONE.ck","new_file":"patches\/percussion\/BKickONE.ck","new_contents":"public class BKickONE {\n\n Mix2 mout;\n dur a, d, s, r;\n float slevel;\n float vol;\n\n float fg, fph, ffr;\n float sg, sph, sfr;\n\n fun void adssr(dur a, dur d, dur s, dur r, float slevel){\n a => this.a;\n d => this.d;\n s => this.s;\n r => this.r;\n slevel => this.slevel;\n }\n\n fun void set_values_direct(float values[]){\n values[0] => this.fg;\n values[1] => this.fph;\n values[2] => this.ffr;\n values[3] => this.sg;\n values[4] => this.sph;\n values[5] => this.sfr;\n }\n\n fun void patch(int n){\n if (n==1) set_values_direct([222.0, -pi, 1.27, -3.1, -pi\/2, .01]);\n }\n\n fun void trigger(float vol){\n vol => this.vol;\n mout.gain(vol);\n spork ~ do_kick();\n }\n\n fun void do_kick(){\n\n \/\/ carrier\n SinOsc s;\n s.gain(vol);\n s => ADSR vEnv => mout;\n\n \/\/ modulator\n SawOsc sawForm => s;\n s.phase(0);\n s.sync(2);\n sawForm.gain(fg);\n sawForm.phase(fph);\n sawForm.freq(ffr);\n\n \/\/ modulate the modulator\n SinOsc sShape => sawForm;\n sawForm.sync(2);\n sShape.gain(sg);\n sShape.phase(sph);\n sShape.freq(sfr);\n\n \/\/ pass time\n vEnv.set(a, d, slevel, r);\n vEnv.keyOn();\n (this.a + this.d + this.s) => now;\n\n vEnv.keyOff();\n this.r => now;\n\n }\n\n \/\/ set defaults\n adssr(2::ms, 171::ms, 0::ms, 35::ms, 0.20);\n patch(1);\n\n}\n\nBKickONE kick;\nkick.mout => dac;\nkick.trigger(.9);\n\n2::second => now;\n\n\/\/ edit -w\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/percussion\/BKickONE.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"9714d91d3688934ae60f88f62c83ea2eda5fbdc1","subject":"Create bassdrum_electric_thud.ck","message":"Create bassdrum_electric_thud.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electric_thud.ck","new_file":"patches\/percussion\/bassdrum_electric_thud.ck","new_contents":"\/\/ bassdrum synthesis\n\/\/ Dealga McArdle, Nov 2013\nSawOsc spitch => SinOsc bd_osc => \nGain preAmp => ADSR bdADSR => Gain master => dac;\n\n1.2 => master.gain;\n20 => bd_osc.freq;\n162.02 => spitch.gain;\n2 => bd_osc.sync;\n.7 => preAmp.gain;\n\nfun void BD1_ON(float pgain){\n bdADSR.set( 2::ms, 181::ms, 0.0, 35::ms );\n pgain => preAmp.gain;\n -1.0 => spitch.phase;\n .5 => spitch.sfreq; \n bdADSR.keyOn();\n}\n\nBD1_ON(.7);\n0.75::second => now;\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/percussion\/bassdrum_electric_thud.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"2fc2edf9e4935b95b54a1ab337afbd1bf94a7d0b","subject":"Create common_functions.ck","message":"Create common_functions.ck\n\ni've used these a lot already.","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/common_functions.ck","new_file":"utility_functions\/common_functions.ck","new_contents":"\/\/ Machine.add(\"utilities.ck\");\n\n\/* \n definitions\n\n fun void repr_int_array(int arr[]){}\n fun void repr_int_array(string arr[]){}\n \n fun int random_from(int arr[]){}\n fun int inArray(int token, int arr[]){}\n fun int indexOfClosest(int ival, int arr[]){}\n fun int to_note(string str){}\n fun int[] randomArray_from(int arr[], int length){}\n fun int[] range(int start, int end){}\n fun int[] narray(int start, int next, int up_to){}\n fun int[][] stepify(string sequence_data[]){}\n \n fun float average(int arr[]){}\n \n fun string repr(int arr[]){}\n fun string repr(string arr[]){}\n fun string[] split(string arr, string token){}\n \n fun SndBuf load_sample(string wavname){}\n\n \n https:\/\/gist.github.com\/anonymous\/7206152\n \n*\/ \n\n\n\nfun string[] split_str(string str, string token){\n\n string collect[0];\n int pos;\n int pos2;\n while( str.find(token) >0){\n str.find(token) => pos2;\n collect << str.substring(pos, pos2);\n str.substring(pos2+1) => str;\n }\n collect << str;\n return collect;\n}\n\n\nfun int random_from(int arr[]){\n return arr[Math.random2(0, arr.cap()-1)];\n}\n\nfun int[] randomArray_from(int arr[], int length){\n \/\/ return new array of capacity length chosing elements from arr\n int generated_arr[0];\n for(0 => int i; i int i; i<=end; i++) arr << i;\n return arr;\n}\n\nfun int[] narray(int start, int next, int up_to){\n \/\/ (start, end..up_to) (inclusive)\n int arr[0];\n start => int cval;\n next - start => int jump;\n for(cval; cval<=up_to; jump +=> cval){\n arr << cval;\n }\n return arr; \/\/ matey!\n}\n\nfun string repr(int arr[]){\n \/*\n this returns a string representation of an int array,\n useful for debug printing.\n *\/\n \"[\" + Std.itoa(arr[0]) => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + Std.itoa(arr[i]) +=> s;\n }\n return s + \"]\";\n}\n\nfun string repr(string arr[]){\n \n \/\/this returns a string representation of a string array,\n \/\/useful for debug printing.\n \n \"[\" + arr[0] => string s;\n for (1 => int i; i < arr.cap(); i++){\n \",\" + arr[i] +=> s;\n }\n return s + \"]\";\n}\n\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun void repr_int_array(string arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"]\";\n chout <= IO.newline();\n}\n\nfun int inArray(int token, int arr[]){\n \/*\n tests membership of an array\n *\/ \n for(0 => int i; i Std.atoi => int oct;\n if (oct < 0 || oct > 10) return -4;\n \n str.substring(0,2) => str;\n \n [ \"C-\",\"C#\",\"D-\",\"D#\",\"E-\",\"F-\",\n \"F#\",\"G-\",\"G#\",\"A-\",\"A#\",\"B-\"\n ] @=> string notes_list[];\n \n \/\/ note must be in this list, else return -3 at the end\n for (0 => int i; i < notes_list.cap(); i++){\n if (str == notes_list[i]){\n return (i + oct * 12);\n }\n }\n return -5; \n}\n\nfun int[][] stepify(string sequence_data[]){\n \/*\n this function converts a string array to an int array,\n it accepts fuzzy formatting:\n \"1..1..1..1..\" becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n \"1..1. .1..1..\" also becomes [1,0,0,1,0,0,1,0,0,1,0,0]\n *\/\n\n sequence_data.cap() => int parts;\n 32 => int steps; \/\/ hard code for now\n <<< parts, steps >>>;\n \n int data_store[parts][steps];\n for(0 => int i; i string seq_string;\n int part_data[0];\n int trigger;\n \/\/<<< seq_string >>>;\n for(0 => int j; j < seq_string.length(); j++){\n seq_string.substring(j,1) => string token; \/\/ crazy\n\n if (token == \" \") continue;\n if (token == \".\") 0 => trigger;\n else if (token == \"1\") 1 => trigger;\n\n part_data << trigger;\n }\n \/\/<<< repr_int_array(part_data)>>>;\n part_data @=> data_store[i];\n }\n return data_store;\n}\n\nfun SndBuf load_sample(string wavname){\n\n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n\n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nfun float average(int arr[]){\n int sum;\n arr.cap() => int num_items;\n for(0 => int i; i < num_items; i++){\n arr[i] +=> sum;\n }\n sum $ float => float fsum;\n num_items $ float => float fcap;\n return fsum \/ fcap;\n}\n\nfun int indexOfClosest(int ival, int arr[]){\n \/\/ will find the closest value to ival in arr\n \/\/ if there are multiple, it will return the first.\n Math.INT_MAX => int min_distance;\n 0 => int diff;\n -1 => int idx_tracker;\n\n for(0 => int i; i diff;\n if (diff < min_distance) \n { \n diff => min_distance;\n i => idx_tracker;\n }\n }\n return idx_tracker;\n\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'utility_functions\/common_functions.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"8f2fbb9cc61fd382db2a4e8cf38f03a723c0a98a","subject":"Create MidiIn2Notes.ck","message":"Create MidiIn2Notes.ck","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/MidiIn2Notes.ck","new_file":"utility_functions\/MidiIn2Notes.ck","new_contents":"MidiIn min;\nMidiMsg msg;\n\n\/\/ open midi receiver, exit on fail\nif ( !min.open(0) ) me.exit(); \n\nint notes[0];\nint ncount;\nwhile( true )\n{\n min => now;\n while( min.recv( msg ) )\n {\n msg.data1 => int mode; \n \/\/<<< mode >>>;\n msg.data2 => int note;\n msg.data3 => int volume;\n \n if (mode == 144) {\n chout <= note;\n chout <= \", \";\n }\n }\n\n chout <= IO.newline(); \n int a[0] @=> notes;\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'utility_functions\/MidiIn2Notes.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"c570210323e6dc59064658a36a2397b5d9c9b56b","subject":"renamed the to mouse","message":"renamed the to mouse\n","repos":"gewang\/ofxChucK,gewang\/ofxChucK","old_file":"example\/ck\/mouse.ck","new_file":"example\/ck\/mouse.ck","new_contents":"\/\/ control LFO's (no sound)\nSinOsc a => blackhole;\nSinOsc b => blackhole;\n\n\/\/ frequencies\n1.1 => a.freq;\n1.13 => b.freq;\n\n\/\/ FM synthesis\nSinOsc c => SinOsc d => dac;\n2 => d.sync;\n\n\/\/ time loop\nwhile( true )\n{\n \/\/ send data to graphics\n VR.setFloat( \"color-x\", (a.last()+1)\/2*620 );\n VR.setFloat( \"color-y\", (b.last()+1)\/2*620 );\n \n \/\/ get values from graphics\n VR.getFloat( \"mouse-x\" ) => d.freq;\n d.freq() * 2 => c.freq;\n VR.getFloat( \"mouse-y\" ) => c.gain;\n\n \/\/ when there is a new graphics draw\n VR.displaySync() => now;\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'example\/ck\/mouse.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"2ab308e04859201b4c788d923e4ed791be090a3e","subject":"Initial record to file","message":"Initial record to file\n","repos":"DataOnAcid\/AudioRenderer,DataOnAcid\/AudioRenderer","old_file":"rec.ck","new_file":"rec.ck","new_contents":"\/\/ chuck this with other shreds to record to file\n\/\/ example> chuck foo.ck bar.ck rec (see also rec2.ck)\n\n\/\/ arguments: rec:\n\n\/\/ get name\nme.arg(0) => string filename;\nif( filename.length() == 0 ) \"audio.mp3\" => filename;\n\n\/\/ pull samples from the dac\ndac => Gain g => WvOut w => blackhole;\n\/\/ this is the output file name\nfilename => w.wavFilename;\n<<<\"writing to file:\", \"'\" + w.filename() + \"'\">>>;\n\/\/ any gain you want for the output\n.5 => g.gain;\n\n\/\/ temporary workaround to automatically close file on remove-shred\nnull @=> w;\n\n\/\/ infinite time loop...\n\/\/ ctrl-c will stop it, or modify to desired duration\nwhile( true ) 1::second => now;\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'rec.ck' did not match any file(s) known to git\n","license":"apache-2.0","lang":"ChucK"} {"commit":"f684aaac33dc537f5b98e0b136c692cd8001cfc8","subject":"adding first turenas example","message":"adding first turenas example\n","repos":"gewang\/ofxChucK,gewang\/ofxChucK","old_file":"example_OculusDK2\/bin\/data\/ck\/turenas-1.ck","new_file":"example_OculusDK2\/bin\/data\/ck\/turenas-1.ck","new_contents":"\n\/\/ keyboard\nHid kb;\n\/\/ hid message\nHidMsg msg;\n\n\/\/ open\nif( !kb.openKeyboard(0) ) me.exit();\n<<< \"KB open:\", kb.name() >>>;\nspork ~ kbf();\n\n\/\/ patch\nSndBuf L => dac.left;\nSndBuf R => dac.right;\n\n\/\/ envelope followers\nL => OnePole envL => blackhole; L => envL; 3 => envL.op;\nR => OnePole envR => blackhole; R => envR; 3 => envR.op;\n.9995 => envL.pole => envR.pole;\n\n\/\/ load\nme.dir() + \"..\/audio\/turenas-L.aiff\" => L.read;\nme.dir() + \"..\/audio\/turenas-R.aiff\" => R.read;\nL.samples() => L.pos;\nR.samples() => R.pos;\n0 => L.gain => R.gain;\n\n-100 => float FRONT;\nFRONT * .5 => float FRONT_FENCE;\n100 => float BACK;\nBACK * .5 => float BACK_FENCE;\n\n\/\/ entities\nVREntity es[0];\nvec3 v;\npolar p;\ncomplex c;\nfun void makeOne()\n{\n \/\/ make a some points\n VR.makeEntity(\"one\"+es.size(),\"mesh\") @=> VREntity mesh;\n \/\/ make\n mesh.eval( \"vertex -1 -1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex 1 -1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex -1 1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n mesh.eval( \"vertex 1 1 0\" );\n \/\/mesh.eval( \"color 1 1 1\" );\n mesh.eval( \"normal 0 0 1\" );\n \/\/ draw as triangle\n mesh.eval( \"draw trianglestrip\" );\n \/\/ add to world\n VR.root().addChild( mesh );\n \/\/ loc\n Math.random2f(5,100) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => mesh.loc.x;\n c.im => mesh.loc.z;\n Math.random2f(FRONT,FRONT_FENCE) => mesh.loc.y;\n \n Math.random2f(.1,1) => mesh.rgba.r;\n Math.random2f(.1,1) => mesh.rgba.g;\n Math.random2f(.1,1) => mesh.rgba.b;\n Math.random2f(0,0) => mesh.rgba.a;\n Math.random2f(0,360) => mesh.ori.y;\n\n \/\/ add\n es << mesh;\n}\n\nVREntity @ es2[0];\nfloat es2t[0];\n\nfun void makeTwo()\n{\n \/\/ make a some points\n VR.makeEntity(\"two\"+es.size(),\"flare\") @=> VREntity f;\n \/\/ set the texture\n f.setString( \"texture\", \"texture:flare-1\");\n \/\/ loc\n Math.random2f(5,100) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => f.loc.x;\n c.im => f.loc.y;\n f.sca.setAll(10);\n Math.random2f(FRONT,FRONT_FENCE) => f.loc.z;\n \n Math.random2f(1,1) => f.rgba.r;\n Math.random2f(1,1) => f.rgba.g;\n Math.random2f(1,1) => f.rgba.b;\n Math.random2f(0,0) => f.rgba.a;\n \n \/\/ add\n es2 << f;\n es2t << Math.random2f(0,2*pi);\n\n \/\/ add to world\n VR.root().addChild( f );\n}\n\nVREntity @ es3[0];\nfloat es3t[0];\n\n-500 => float FRONT3;\nFRONT3 * .5 => float FRONT_FENCE3;\n300 => float BACK3;\nBACK3 * .5 => float BACK_FENCE3;\n\nfun void makeThree( float inner, float outer, float whereY, float varyY )\n{\n \/\/ make a some points\n VR.makeEntity(\"three\"+es.size(),\"mesh\") @=> VREntity f;\n \/\/ set the texture\n f.setString( \"texture\", \"texture:flare-1\");\n \n f.eval( \"draw points\" );\n repeat(4000)\n {\n \/\/ loc\n Math.random2f(inner,outer) => p.mag;\n Math.random2f(-pi,pi) => p.phase;\n p$complex => c;\n c.re => v.x;\n Math.random2f(-1,1) => v.y;\n c.im => v.z;\n f.eval( \"vertex\", v );\n }\n \n 0 => f.loc.x;\n 0 => f.loc.z;\n Math.random2f(whereY,whereY*varyY) => f.loc.y;\n \n Math.random2f(1,1) => f.rgba.r;\n Math.random2f(1,1) => f.rgba.g;\n Math.random2f(1,1) => f.rgba.b;\n Math.random2f(0,0) => f.rgba.a;\n \n \/\/ add\n es3 << f;\n es3t << .0000002 \/ Math.pow((inner+outer)\/6.0\/outer,10);\n \/\/ <<< \"spin:\", es3t[es3t.size()-1] >>>;\n\n \/\/ add to world\n VR.root().addChild( f );\n}\n\n\n\/\/repeat(4)\n\/\/ for(int i; i < 10; i++ )\n\/\/ makeThree( 2*(20+i*15), 4*(20+i*15+5), FRONT3*3, .6 );\n\n\/\/repeat(4)\n\/\/ for(int i; i < 10; i++ )\n\/\/ makeThree( 2*(20+i*15), 4*(20+i*15+5), FRONT3*6, .6 );\n\n\/\/repeat(4)\n\/\/ for(int i; i < 10; i++ )\n\/\/ makeThree( 2*(20+i*15), 4*(20+i*15+5), FRONT3*12, .6 );\n\n\n\/\/ disable lights\nVR.allLightsOn();\n\n\/\/ bang detector\nfun void bangDetect()\n{\n while( true )\n {\n if( envL.last() > 0.0001 )\n {\n <<< \"BANG!!\", now\/second >>>;\n 100::ms => now;\n }\n 10::ms => now;\n }\n}\n\n\/\/ detector\n\/\/ spork ~ bangDetect();\nVREntity @ e;\n\n\/\/ loop\nwhile( true )\n{\n for( int i; i < es.size(); i++ )\n {\n es[i] @=> e;\n if( e.loc.y <= FRONT_FENCE )\n 1-Math.fabs((e.loc.y-FRONT_FENCE)\/(FRONT-FRONT_FENCE)) => e.rgba.a;\n else if( e.loc.y >= BACK_FENCE )\n 1-Math.fabs((e.loc.y-BACK_FENCE)\/(BACK-BACK_FENCE)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n \n if( e.rgba.a < 0 ) 0 => e.rgba.a;\n else if( e.rgba.a > 1 ) 1 => e.rgba.a;\n \n 5 +=> e.ori.y;\n .5 +=> e.loc.y;\n if( e.loc.y > BACK ) FRONT => e.loc.y;\n }\n \n for( int i; i < es2.size(); i++ )\n {\n es2[i] @=> e;\n if( e.loc.z <= FRONT_FENCE )\n 1-Math.fabs((e.loc.z-FRONT_FENCE)\/(FRONT-FRONT_FENCE)) => e.rgba.a;\n else if( e.loc.z >= BACK_FENCE )\n 1-Math.fabs((e.loc.z-BACK_FENCE)\/(BACK-BACK_FENCE)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n\n if( e.rgba.a < 0 ) 0 => e.rgba.a;\n else if( e.rgba.a > 1 ) 1 => e.rgba.a;\n \n Math.pow(envL.last(),1)*100 *=> e.rgba.a;\n\n 5 * (1 + .2*Math.sin(es2t[i])) => e.sca.setAll; .1 +=> es2t[i];\n .2 +=> e.loc.z;\n if( e.loc.z > BACK ) FRONT => e.loc.z;\n }\n \n for( int i; i < es3.size(); i++ )\n {\n es3[i] @=> e;\n if( e.loc.y <= FRONT_FENCE3 )\n 1-Math.fabs((e.loc.y-FRONT_FENCE3)\/(FRONT3-FRONT_FENCE3)) => e.rgba.a;\n else if( e.loc.y >= BACK_FENCE3 )\n 1-Math.fabs((e.loc.y-BACK_FENCE3)\/(BACK3-BACK_FENCE3)) => e.rgba.a;\n else\n 1 => e.rgba.a;\n \n if( e.rgba.a < 0 ) 0 => e.rgba.a;\n else if( e.rgba.a > 1 ) 1 => e.rgba.a;\n \n es3t[i] +=> e.ori.y;\n .5 +=> e.loc.y;\n if( e.loc.y > BACK3 ) FRONT3 => e.loc.y;\n }\n \n \/\/ VR.root().rgba.setAll(Math.pow(envL.last(),.75)*500);\n \n \/\/ synch with display\n VR.displaySync() => now;\n}\n\nfun void kbf()\n{\n while( true )\n {\n \/\/ wait\n kb => now;\n \/\/ wait\n while( kb.recv(msg) )\n {\n if( !msg.isButtonDown() )\n continue;\n\n if( msg.ascii == 48 ) \/\/ 1\n {\n 0 => L.pos => R.pos;\n 1 => L.gain => R.gain;\n }\n \/\/ <<< \"kb:\", msg.ascii >>>;\n if( msg.ascii == 49 ) \/\/ 1\n {\n repeat(10) makeOne();\n }\n else if( msg.ascii == 50 ) \/\/ 2\n {\n repeat(10) makeTwo();\n }\n else if( msg.ascii == 51 ) \/\/ 3\n {\n for(int i; i < 10; i++ )\n makeThree( 2*(20+i*15), 4*(20+i*15+5), FRONT3*2.5, .75 );\n }\n }\n }\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'example_OculusDK2\/bin\/data\/ck\/turenas-1.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"090f48848ae4f9bff5aea1fec12db26433d694f7","subject":"oh damn, oscbank should have been added earlier.","message":"oh damn, oscbank should have been added earlier.\n","repos":"jordanorelli\/wii-chuck-synth","old_file":"oscbank.ck","new_file":"oscbank.ck","new_contents":"public class OscBank\n{\n int width;\n int height;\n int columnStep;\n int rowStep;\n string currentPatch;\n float baseFreq;\n float octaveSteps;\n UGen @ bank[][];\n Gain @ gains[][];\n\n fun static OscBank OscBank(int width, int height, int columnStep,\n int rowStep, float baseFreq, float octaveSteps)\n {\n return OscBank(width, height, columnStep, rowStep, baseFreq,\n octaveSteps, true);\n }\n\n fun static OscBank OscBank(int width, int height, int columnStep,\n int rowStep, float baseFreq, float octaveSteps,\n int autoPatch)\n {\n OscBank oscBank;\n width => oscBank.width;\n height => oscBank.height;\n columnStep => oscBank.columnStep;\n rowStep => oscBank.rowStep;\n baseFreq => oscBank.baseFreq;\n octaveSteps => oscBank.octaveSteps;\n new UGen[width][height] @=> oscBank.bank;\n new Gain[width][height] @=> oscBank.gains;\n\n ToneCalc.grid(width, height, columnStep, rowStep, baseFreq, octaveSteps)\n @=> float toneMap[][];\n\n for(0 => int i; i < width; i++)\n {\n for(0 => int j; j < height; j++)\n {\n TriOsc s;\n toneMap[i][j] => s.freq;\n\n Gain g;\n 0 => g.gain;\n s @=> oscBank.bank[i][j] => g @=> oscBank.gains[i][j];\n }\n }\n\n if(autoPatch == true)\n {\n oscBank.patch();\n }\n\n return oscBank;\n }\n\n fun int checkRange(int column, int row)\n {\n return !(column < 0\n || column >= width\n || row < 0\n || row >= height);\n }\n\n fun int checkRange(int column, int row, string identifier)\n {\n checkRange(column, row) => int val;\n if(!val)\n cherr <= \"[Out of range in OscBank.\" <= identifier <= \"()]\\t\"\n <= column <= \"\\t\" <= row <= \"\\t\" <= IO.newline();\n return val;\n }\n\n fun void setPatch(string targetPatch)\n {\n for(0 => int i; i < width; i++)\n for(0 => int j; j < height; j++)\n setPatch(targetPatch, i, j);\n }\n\n fun void setPatch(string targetPatch, int column, int row)\n {\n if(!checkRange(column, row, \"setPatch\"))\n return;\n\n Osc s;\n if(targetPatch == \"SinOsc\")\n {\n new SinOsc @=> s;\n }\n else if(targetPatch == \"SqrOsc\")\n {\n new SqrOsc @=> s;\n }\n else if(targetPatch == \"SawOsc\")\n {\n new SawOsc @=> s;\n }\n else if(targetPatch == \"TriOsc\")\n {\n new TriOsc @=> s;\n }\n else\n {\n cherr <= \"Unrecognized targetPatch supplied in OscBank.setPatch:\"\n <= targetPatch <= IO.newline();\n }\n\n toneMap()[column][row] => s.freq;\n 0 => bank[column][row].op;\n bank[column][row] =< gains[column][row];\n s @=> bank[column][row] => gains[column][row];\n }\n\n fun void patch()\n {\n for(0 => int i; i < bank.size(); i++)\n {\n for(0 => int j; j < bank[0].size(); j++)\n {\n gains[i][j] => dac;\n }\n }\n }\n\n fun void unpatch()\n {\n for(0 => int i; i < bank.size(); i++)\n for(0 => int j; j < bank[0].size(); j++)\n unpatch(i, j);\n }\n\n fun void unpatch(int column, int row)\n {\n gains[column][row] =< dac;\n }\n\n fun void rebase(float freq)\n {\n for(0 => int i; i < bank.size(); i++)\n {\n for(0 => int j; j < bank[0].size(); j++)\n {\n bank[i][j] =< dac;\n }\n }\n }\n\n fun float getFreq(int column, int row)\n {\n if(checkRange(column, row))\n {\n return toneMap()[column][row];\n }\n else\n return 220.0;\n }\n\n fun void setGain(int column, int row, int value)\n {\n if(checkRange(column, row, \"setGain\"))\n value => bank[column][row].gain;\n }\n\n fun float getGain(int column, int row)\n {\n if(checkRange(column, row, \"getGain\"))\n return bank[column][row].gain();\n else\n return 0.0;\n }\n\n fun int getOp(int column, int row)\n {\n if(checkRange(column, row, \"getOp\"))\n return bank[column][row].op();\n else\n return false;\n }\n\n fun void setOp(int value)\n {\n if(value != 0 && value != 1 && value != false && value != true)\n {\n cherr <= \"Invalid value sent to OscBank.setOp():\" <= value\n <= IO.newline();\n for(0 => int i; i < width; i++)\n {\n for(0 => int j; j < height; j++)\n {\n 0 => bank[i][j].op;\n }\n }\n }\n else\n {\n for(0 => int i; i < width; i++)\n {\n for(0 => int j; j < height; j++)\n {\n value => bank[i][j].op;\n }\n }\n }\n }\n\n fun float[][] toneMap()\n {\n return ToneCalc.grid(width, height, columnStep, rowStep, baseFreq, octaveSteps);\n }\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'oscbank.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"6502053f2b17587440eb06251d68e6ba82415927","subject":"Create perc_electric_slapclap(PercSynC).ck","message":"Create perc_electric_slapclap(PercSynC).ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/perc_electric_slapclap(PercSynC).ck","new_file":"patches\/percussion\/perc_electric_slapclap(PercSynC).ck","new_contents":"","old_contents":"","returncode":2,"stderr":"\/bin\/sh: 1: Syntax error: \"(\" unexpected\n","license":"mit","lang":"ChucK"} {"commit":"5bf196df16ff70767bec94c5a24e1c562b284623","subject":"Create bassdrum_electronic_deepboom.ck","message":"Create bassdrum_electronic_deepboom.ck\n\nnot great, but it's a start, named SynC because it should retrigger on a specific phase each time, C means it's driven by a curve. (curve not implemented in this version)","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electronic_deepboom.ck","new_file":"patches\/percussion\/bassdrum_electronic_deepboom.ck","new_contents":"\/\/ Assignment 7 drumCircleDSP\n\npublic class KickSynC{\n\n Gain bdmaster2 => dac;\n bdmaster2.gain(0.02);\n\n fun void trigger(float volume){\n \/* this makes it possible to trigger \n the bassdrum in a new thread *\/\n spork ~ s_do_kick(volume);\n }\n\n fun void s_do_kick(float volume){\n\n 3850 => float frequency;\n\n SinOsc bd_osc => \n Gain preAmp => HPF bf => ADSR volEnv => \n PoleZero dc => LPF highs => bdmaster2;\n \n dc.blockZero(0.99);\n bf.freq(50);\n bf.Q(4.1);\n highs.freq(332);\n \n volEnv.set( 1::ms, 181::ms, 0.3, 35::ms );\n bdmaster2.gain(volume);\n\n 1 => int fa;\n 44 => int fd;\n 50 => int fs;\n 120 => int fr;\n\n 44100\/frequency => float grain;\n\n Step s5 => ADSR pitchEnv => blackhole;\n pitchEnv.set(fa::ms, (fd\/1.2)::ms, fs\/100, fr::ms);\n pitchEnv.keyOn(1);\n volEnv.keyOn(1);\n (140)::ms + now => time later;\n while(now < later)\n {\n 850 => int min_freq;\n 51 => int bass_freq;\n ((pitchEnv.last()*220) + min_freq) $ int => int pitch_curve;\n Math.max(pitch_curve, bass_freq) - 800.0 => float debug_freq => bd_osc.freq;\n\n grain::samp => now;\n\n if( now > later){\n (120)::ms => now;\n volEnv.keyOff(1);\n pitchEnv.keyOff(1);\n }\n }\n\n\n\n 1.5::second => now;\n bd_osc =< preAmp;\n\n }\n\n}\n\nKickSynC kick1;\n\nkick1.trigger(0.5);\n\n1::second => now;\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/percussion\/bassdrum_electronic_deepboom.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"5818bd1062d4bed90ad19244f364904c1cc8cab6","subject":"Create bassdrum_electronic_nice_thud.ck","message":"Create bassdrum_electronic_nice_thud.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electronic_nice_thud.ck","new_file":"patches\/percussion\/bassdrum_electronic_nice_thud.ck","new_contents":"\/\/ I would appreciate if you would link to this source if you use this patch.\n\npublic class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume\/4.1);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 1590, -7.98, \n 0.017, 440, -.98, \n 0.05, 140, -.98, \n .17, 114, 0, \n .61, 54, 0, \n 1.8, 41.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 460::ms, 0.0, 125::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 221::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n Dyno comp => bdmast;\n comp.compress();\n SinOsc form => volE => LPF boom => PoleZero dc => comp; \n dc.blockZero(0.994);\n 1222 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(.26);\n 21::samp => now;\n\n \/\/ advance time\n if (now > (start + 280::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\n\/*\n Usage docs\n\n KickSynC kick1;\n\n kick1.bdmast => dac;\n kick1.bdmast => NRev blunk => dac;\n blunk.gain(0.01);\n blunk.mix(0.2);\n\n for(0 => int i; i<5; i++){\n kick1.trigger(4.4);\n 0.5::second => now;\n }\n*\/\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/percussion\/bassdrum_electronic_nice_thud.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"454f6148bb6ab0cad4b0ffd65cffd8719701a564","subject":"Create LiSa_LiveSampler_from_SndBuf.ck","message":"Create LiSa_LiveSampler_from_SndBuf.ck","repos":"zeffii\/ChucKScripts","old_file":"demo_files\/LiSa_LiveSampler_from_SndBuf.ck","new_file":"demo_files\/LiSa_LiveSampler_from_SndBuf.ck","new_contents":"fun SndBuf load_sample(string wavname){\n \n \/\/ usage\n \/\/ load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n \/\/ return a reference to a new buffer object.\n SndBuf temp_buff;\n me.dir() + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n \n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain;\n return temp_buff;\n}\n\nload_sample(\"hihat_04\") @=> SndBuf perc_sample;\nperc_sample => Gain master_sample => dac;\nmaster_sample => Pan2 sample_pan => dac;\n\nLiSa liveSampl1 => NRev rname => Gain big => dac;\n(10*240*22)::samp => dur bigtime => liveSampl1.duration; \n\nrname.mix(0.2);\nmaster_sample => liveSampl1;\nbig.gain(4);\n\n1 => liveSampl1.record;\nfor(2 => int j; j<10; j++){\n ((((j%2)*2)-1)*.9) => sample_pan.pan;\n for(0 => int i; i<240; i++){\n 0.01 => master_sample.gain;\n 0 + (i*j*142)=> perc_sample.pos;\n 22::samp => now;\n }\n}\n0 => liveSampl1.record;\n\nfor(0 => int i; i<4; i++){\n 0 => liveSampl1.playPos;\n -.3 => liveSampl1.rate;\n 1 => liveSampl1.play;\n bigtime => now;\n 0 => liveSampl1.play;\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'demo_files\/LiSa_LiveSampler_from_SndBuf.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"e341858175a80fa92d0b6fb27a5f9b9169c59850","subject":"Chord Progression","message":"Chord Progression\n\nA raw chord progression file\n","repos":"SIGMusic\/tonal-soundfield","old_file":"chordProgression.ck","new_file":"chordProgression.ck","new_contents":"\/* As you can see, this is a very raw Markov chain for chord progressions\n * It would be great if melodies can be generated according to this state machine\n * I use classes only because a ton of \"else if\" looks really messy, though the object-oriented of this language is really bad\n * The blank funcion is intended for future data receiving\n * It sends basic information of a chord\n * I hope melody can be generated according to the chord\n *\/\n \n\/\/the very basic chord base\nclass Chord\n{\n string name; \/\/how you call it\n string nextChord[]; \/\/next states\n int root; \/\/the root key\n int type; \/\/major,minor,etc\n float probability[]; \/\/probability for each next state\n fun string getNextChordName() \/\/randomly choose the next chord\n {\n Std.rand2f(0, 1)=>float rand;\n 0=>float c;\n for (0=>int i; ic;\n if (rand<=c)\n return nextChord[i];\n }\n return this.name;\n }\n fun void setStyle(){} \/\/may be used to change probabilities\n}\n\nclass ChordMajor extends Chord\n{\n 0=>type;\n}\n\nclass ChordMinor extends Chord\n{\n 1=>type;\n}\n\nclass ChordI extends ChordMajor\n{\n \"I\"=>name;\n 0=>root;\n [\"I\", \"ii\",\"III\",\"IV\",\"V\"]@=>nextChord;\n [0.1,0.1,0.1,0.4,0.3]@=>probability;\n}\nclass Chordii extends ChordMinor\n{\n \"ii\"=>name;\n 2=>root;\n [\"I\",\"iii\",\"III\",\"V\",\"vi\"]@=>nextChord;\n [0.1,0.1,0.3,0.4,0.1]@=>probability;\n}\nclass Chordiii extends ChordMinor\n{\n \"iii\"=>name;\n 4=>root;\n [\"V\",\"IV\",\"vi\"]@=>nextChord;\n [0.2,0.4,0.4]@=>probability;\n}\nclass ChordIII extends ChordMajor\n{\n \"III\"=>name;\n 4=>root;\n [\"IV\",\"vi\"]@=>nextChord;\n [0.4,0.6]@=>probability;\n}\nclass ChordIV extends ChordMajor\n{\n \"IV\"=>name;\n 5=>root;\n [\"I\",\"V\",\"III\"]@=>nextChord;\n [0.3,0.6,0.1]@=>probability;\n}\nclass ChordV extends ChordMajor\n{\n \"V\"=>name;\n 7=>root;\n [\"I\",\"vi\",\"ii\"]@=>nextChord;\n [0.6,0.3,0.1]@=>probability;\n}class Chordvi extends ChordMinor\n{\n \"vi\"=>name;\n 9=>root;\n [\"I\",\"ii\",\"iii\",\"IV\",\"V\",\"vi\"]@=>nextChord;\n [0.1,0.3,0.1,0.3,0.1,0.1]@=>probability;\n}\n\n\/\/runing code starts here\nOscSend send;\n\"localhost\" => string hostname;\n6449 => int port;\nsend.setHost(hostname,port);\nChord current;\nChordI I;\nChordii ii;\nChordiii iii;\nChordIII III;\nChordIV IV;\nChordV V;\nChordvi vi;\nfun Chord getChord(string s)\n{\n if (s==\"I\")\n return I;\n if (s==\"ii\")\n return ii;\n if (s==\"iii\")\n return iii;\n if (s==\"III\")\n return III;\n if (s==\"IV\")\n return IV;\n if (s==\"V\")\n return V;\n if (s==\"vi\")\n return vi;\n return null;\n}\nI @=> current;\nwhile (true)\n{\n <<< \"Chord Name: \", current.name >>>;\n 0=>int key;\n current.root=>int root;\n current.type=>int type;\n key => send.addInt;\n root => send.addInt;\n type => send.addInt;\n <<< \"Sent key: \", key, \"root: \", root, \", type: \", type >>>;\n getChord(current.getNextChordName())@=>current;\n 6::second=>now;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'chordProgression.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"87f8031956c6df79d3520461749ab6d1b4d93b77","subject":"Adding a basic implementation in ChucK","message":"Adding a basic implementation in ChucK\n","repos":"ayoungblood\/daisy-bell,ayoungblood\/daisy-bell,ayoungblood\/daisy-bell,ayoungblood\/daisy-bell,ayoungblood\/daisy-bell,ayoungblood\/daisy-bell,ayoungblood\/daisy-bell,ayoungblood\/daisy-bell,ayoungblood\/daisy-bell","old_file":"chuck\/daisy-basic.ck","new_file":"chuck\/daisy-basic.ck","new_contents":"\/\/ daisy-basic.ck\n\/\/ Simple ChucK implementation of Daisy Bell\n\n\/\/ pitch and time data\n[74, 71, 67, 62, 64, 66, 67, 64, 67, 62,\n 69, 74, 71, 67, 64, 66, 67, 69, 71, 69,\n 71, 72, 71, 69, 74, 71, 69, 67, 69, 71, 67, 64, 67, 64, 62,\n 62, 67, 71, 69, 67, 71, 69, 71, 72, 74, 71, 67, 69, 62, 67] @=> int DAISY_P[];\n\n[ 3, 3, 3, 3, 1, 1, 1, 2, 1, 6,\n 3, 3, 3, 3, 1, 1, 1, 2, 1, 6,\n 1, 1, 1, 1, 2, 1, 1, 4, 1, 2, 1, 2, 1, 1, 5,\n 1, 2, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 5] @=> int DAISY_T[];\n\n0.180 => float QUARTER; \/\/ quarter note length, in seconds\n\nSinOsc osc => Envelope env => dac; \/\/ define signal chain\n\n\/\/ loop through and play notes\n0 => int i;\nwhile (i osc.freq; \/\/ set frequency\n \n 5::ms => dur d => env.duration; \/\/ attack\n 1.0 => env.target;\n 5::ms => now;\n \n DAISY_T[i]*QUARTER => float t; \/\/ release\n t => env.time;\n 0.0 => env.target;\n t::second => now;\n \n ++i;\n}\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'chuck\/daisy-basic.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"a1f66d826502932575a25c964944937a38527c20","subject":"Create dBFStoGain.ck","message":"Create dBFStoGain.ck\n\nSee source comments","repos":"zeffii\/ChucKScripts","old_file":"dBFStoGain.ck","new_file":"dBFStoGain.ck","new_contents":"\/* Allows inputting a dBFS value like a normal (sound engineer)\nperson (e.g. -6dB for a \"tame\" peak value), and getting a\nChucK \"gain\" number out (e.g. for -6dB, 0.501187).\nThe results seem to indicate that ChucK's gain, calculated\nusing the 'Std.dbtorms()' method, conforms to amplitude\n(as a ratio) as shown in the chart at the top of\nhttp:\/\/en.wikipedia.org\/wiki\/Decibel.\n\nI'd call it verified:\ndBFStoGain( x ) = y\n +3 = ~1.4\n 0 = 1 \/\/ Unity gain\n -6 = ~0.5\n-12 = ~0.25\n*\/\n\n\/\/ Not exactly rocket science >_<\nfun float dBFStoGain(float dBFS){ \n return Std.dbtorms( dBFS + 100 );\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'dBFStoGain.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"5642d633d6304a6663980b6f23ff6f6463fbc61a","subject":"sandbox script for playing with chuck filters","message":"sandbox script for playing with chuck filters\n","repos":"beefoo\/music-lab-scripts,shawngraham\/music-lab-scripts,beefoo\/music-lab-scripts,rblades\/music-lab-scripts,beefoo\/music-lab-scripts","old_file":"sandbox\/filters.ck","new_file":"sandbox\/filters.ck","new_contents":"\/*\n* Script for playing with adsr\n*\/\n\n4000 => int interval;\n\n\/\/ adsr\nADSR adsr;\n200 => int a;\n800 => int d;\ninterval - a - d => int r;\nadsr.set( a::ms, d::ms, 0, r::ms );\n\n\/\/ reverb\n\/\/JCRev rvb;\n\/\/NRev rvb;\nPRCRev rvb;\n0.1 => rvb.mix;\n\n\/\/ echo\nEcho echo;\n0.5 => echo.mix;\n500::ms => echo.delay;\n1000::ms => echo.max;\n\n\/\/ chorus\nChorus chrs;\n0.5 => chrs.modFreq;\n0.5 => chrs.modDepth;\n0.5 => chrs.mix;\n\n\/\/ pitch shift\nPitShift pts;\n0.5 => pts.mix;\n0.5 => pts.shift;\n\n\/\/ sndbuf\nSndBuf instrument;\nme.dir() + \"\/dating\/instruments\/marvin1a.wav\" => instrument.read;\ninstrument.samples() => instrument.pos;\n\n\/\/ instrument => adsr => echo => rvb => dac;\ninstrument => echo => rvb => chrs => dac;\n\/\/ instrument => pts => dac;\n\nwhile(true) { \n adsr.keyOn();\n 0 => instrument.pos;\n 1 => instrument.gain;\n 1 => instrument.rate;\n interval::ms => now;\n adsr.keyOff();\n}\n\n\n<<< \"Done.\" >>>;\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'sandbox\/filters.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"b4cbfa84f5b0813860c7295797cad127165bf067","subject":"Create vibraphoney.ck","message":"Create vibraphoney.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/melodic\/vibraphoney.ck","new_file":"patches\/melodic\/vibraphoney.ck","new_contents":"Gain vibGain => dac;\n\nvibGain.gain(4.0);\n\n[46, 48, 49, 51, 53, 54, 56, 58] @=> int scale[];\n\nrepeat(3){\n for(0 => int i; i < scale.cap(); i++)\n { \n <<< i >>>;\n scale[i] => int note;\n spork ~ play_vibra(note);\n .2::second => now;\n }\n}\n\nfun void play_vibra(int note){\n\n ModalBar modalBar => ADSR vibEnv => vibGain;\n 320 => modalBar.vibratoFreq;\n 6 => modalBar.preset;\n\n \/\/int, float (0.0 128.0)\n modalBar.controlChange(2, 123.0); \/\/ - Stick Hardness\n modalBar.controlChange(4, 27.0); \/\/ - Stick Position\n modalBar.controlChange(11, 53.0); \/\/ - Vibrato Gain \n modalBar.controlChange(7, 115.0); \/\/ - Vibrato Frequency\n modalBar.controlChange(1, 0.01); \/\/ - Direct Stick Mix\n modalBar.controlChange(128, 0.2); \/\/ - Volume\n\n vibEnv.set( 42::ms, 371::ms, 0.80, 35::ms ); \/\/a, d, s, r\n vibEnv.keyOn();\n Std.mtof(note)*2 => modalBar.freq;\n 1.0 => modalBar.noteOn; \n .75 => modalBar.strike;\n 1.4::second => now;\n\n modalBar =< vibGain;\n\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/melodic\/vibraphoney.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"67b0a3f395def13083ac3082b8132bc9840d7137","subject":"Create WaveformMixerMono.ck","message":"Create WaveformMixerMono.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/WaveformMixerMono.ck","new_file":"patches\/WaveformMixerMono.ck","new_contents":"public class WaveformMixerMono{\n \n SinOsc vsin => Gain final;\n SawOsc vsaw => final;\n TriOsc vtri => final;\n PulseOsc vpls => final; \n Noise vnse => final;\n \n 440 => float frequency;\n \n fun void freq(float frequency){\n frequency => this.frequency;\n vsin.freq(frequency);\n vsaw.freq(frequency);\n vtri.freq(frequency);\n vpls.freq(frequency);\n }\n \n fun void mixer(float components[]){\n \/\/ set defautls, just in case -- make it a SinOsc\n if (!(components.cap() == 5)) {\n [1.0, 0.0, 0.0, 0.0, 0.0] @=> components;\n }\n \n float summer;\n for(0 => int i; i summer;\n }\n \n if (summer <= 0.0) { \n <<< \"no sound!\" >>>;\n 0.0 => this.vsin.gain;\n 0.0 => this.vsaw.gain;\n 0.0 => this.vtri.gain;\n 0.0 => this.vpls.gain;\n 0.0 => this.vnse.gain;\n }\n else{\n components[0] \/ summer => this.vsin.gain;\n components[1] \/ summer => this.vsaw.gain;\n components[2] \/ summer => this.vtri.gain;\n components[3] \/ summer => this.vpls.gain;\n components[4] \/ summer => this.vnse.gain;\n }\n }\n}\n \nWaveformMixerMono bloop;\nbloop.final => dac;\nbloop.final.gain(0.4);\nbloop.mixer([0.0, 0.0, 1.0, 0.0, 0.0]);\nbloop.freq(500.0);\n \n2::second => now;\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/WaveformMixerMono.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"79fd91cb0c2904a12c87dbe61992377ce03abf1b","subject":"Create chuck_midi_in_to_notes_array.ck","message":"Create chuck_midi_in_to_notes_array.ck\n\na little iffy.","repos":"zeffii\/ChucKScripts","old_file":"demo_files\/chuck_midi_in_to_notes_array.ck","new_file":"demo_files\/chuck_midi_in_to_notes_array.ck","new_contents":"\/\/ MidiIn min;\n\/\/ MidiMsg msg;\n\n\/\/ \/\/ open midi receiver, exit on fail\n\/\/ if ( !min.open(0) ) me.exit(); \n\n\/\/ while( true )\n\/\/ {\n\/\/ \/\/ wait on midi event\n\/\/ min => now;\n\n\/\/ \/\/ receive midimsg(s)\n\/\/ while( min.recv( msg ) )\n\/\/ {\n\/\/ \/\/ print content\n\/\/ <<< msg.data1, msg.data2, msg.data3 >>>;\n\/\/ }\n\/\/ }\n\nMidiIn min;\nMidiMsg msg;\n\n\/\/ open midi receiver, exit on fail\nif ( !min.open(0) ) me.exit(); \n\nint notes[0];\nwhile( true )\n{\n \/\/ wait on midi event\n min => now;\n\n \/\/ receive midimsg(s)\n while( min.recv( msg ) )\n {\n \/\/ print content\n msg.data1 => int mode;\n msg.data2 => int note;\n msg.data3 => int volume;\n\n if (mode == 128) notes << note;\n \/\/else { [] @=> notes; }\n }\n if (notes.cap() > 0) {\n repr_int_array(notes);\n }\n int a[0] @=> notes;\n}\n\n\/\/ array\nfun void repr_int_array(int arr[])\n{\n arr.cap() => int num_items;\n chout <= \"[\";\n for(0 => int i; i0) chout <= \",\"; \n chout <= arr[i];\n }\n chout <= \"] @=> int notes[];\";\n chout <= IO.newline();\n}\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'demo_files\/chuck_midi_in_to_notes_array.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"484672af9d4df67f6558bde1aaf948b90f7d7534","subject":"quicksort in chuck","message":"quicksort in chuck\n","repos":"abramhindle\/abrams-chuck-snippets,abramhindle\/abrams-chuck-snippets,abramhindle\/abrams-chuck-snippets","old_file":"quicksort.ck","new_file":"quicksort.ck","new_contents":"\/*\n \n Quicksort implementation in chuck.\n Copyright (C) 2016 Abram Hindle, Ge Wang\n \n This program is free software; you can redistribute it and\/or\n modify it under the terms of the GNU General Public License\n as published by the Free Software Foundation; either version 2\n of the License, or (at your option) any later version.\n \n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n \n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n \n*\/\n\n\/\/ fill arr with values 0 to size-1\nfunction void fillrange(int arr[], int size) {\n for (0 => int i; i < size; 1 +=> i) {\n i => arr[i];\n }\n}\n\n\/\/ reverse the order of elements in arr\nfunction void reverse(int arr[]) {\n arr.cap() \/ 2 => int mid;\n arr.cap() => int s;\n int tmp;\n for (0 => int i; i < mid; i + 1 => i) {\n arr[i] => tmp;\n arr[s - 1 - i] => arr[i];\n tmp => arr[s - 1 - i]; \n }\n}\n\n\/\/ quicksort, call with your arr of indices and float values\n\/\/ quicksort(indices, values, 0, values.cap() - 1) sorts indices\nfunction void quicksort(int arr[], float values[], int lo, int hi) {\n if (lo < hi) {\n partition(arr, values, lo,hi) => int p;\n quicksort(arr, values, lo, p - 1);\n quicksort(arr, values, p + 1, hi);\n }\n}\n\nfunction int partition(int arr[], float values[], int lo, int hi) {\n int tmp;\n values[arr[hi]] => float pivot;\n lo => int i;\n for ( lo => int j; j <= hi - 1 ; j + 1 => j) {\n if (values[arr[j]] <= pivot) {\n arr[i] => tmp;\n arr[j] => arr[i];\n tmp => arr[j];\n i + 1 => i;\n }\n }\n arr[i] => tmp;\n arr[hi] => arr[i];\n tmp => arr[hi];\n return i;\n}\n\n\/\/ fisher-yates shuffle\nfunction void shuffle(int arr[], int size) {\n for (0 => int i; i < size -2; i + 1 => i) {\n Math.random2(i,size-1) => int j;\n arr[i] => int tmp;\n arr[j] => arr[i];\n tmp => arr[j];\n }\n}\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'quicksort.ck' did not match any file(s) known to git\n","license":"apache-2.0","lang":"ChucK"} {"commit":"fdffa210128f6fd53b546b9b3ac51bac61092d2b","subject":"Added Solution.ck file. Configured with fixes that disable the signature.","message":"Added Solution.ck file. Configured with fixes that disable the signature.\n","repos":"Invenietis\/CK-Stamp","old_file":"Solution.ck","new_file":"Solution.ck","new_contents":"\ufeff\n\n 2<\/c:Version>\n CK-Stamp<\/c:Name>\n \n Standard shared key file must exist.<\/c:Disabled>\n Remove FileVersionAttribute in SharedAssemblyInfo.cs.<\/c:Disabled>\n Ensures Version Attributes in SharedAssemblyInfo.cs.<\/c:Disabled>\n Assembly 'CK.Stamp.Fody' must be signed.<\/c:Disabled>\n Assemblies that 'CK.Stamp.Fody' references must be signed.<\/c:Disabled>\n <\/c:Fixes>\n \n \n \n \n <\/c:InfoReleaseDatabase>\n<\/c:Solution>","old_contents":"","returncode":1,"stderr":"error: pathspec 'Solution.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"aa1058e4ebc08ac720ffb9d5dc9b7ab5463a952b","subject":"Create to_stereo_wav_with_gainParams.ck","message":"Create to_stereo_wav_with_gainParams.ck","repos":"zeffii\/ChucKScripts","old_file":"wave_writer\/to_stereo_wav_with_gainParams.ck","new_file":"wave_writer\/to_stereo_wav_with_gainParams.ck","new_contents":"\/\/me.arg(0) => string filename;\n\/\/if( filename.length() == 0 ) \"foo.wav\" => filename;\n\ndac => WvOut2 w => blackhole;\n\/\/\"data\/session\" => w.autoPrefix;\n\"woooot.wav\" => w.wavFilename;\n1 => w.record;\n3::second => now;\n\n\/\/ everything in between\n\n\n0 => w.record;\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'wave_writer\/to_stereo_wav_with_gainParams.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"dba56a6da06da4b2ad316a5db8286bb567d0bb30","subject":"Create perc_electric_versatyle(PercSynC).ck","message":"Create perc_electric_versatyle(PercSynC).ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/perc_electric_versatyle(PercSynC).ck","new_file":"patches\/percussion\/perc_electric_versatyle(PercSynC).ck","new_contents":"","old_contents":"","returncode":2,"stderr":"\/bin\/sh: 1: Syntax error: \"(\" unexpected\n","license":"mit","lang":"ChucK"} {"commit":"2939e679aa117d31c99cb89a664b23b71917b963","subject":"First rewrite of Panner beet","message":"First rewrite of Panner beet\n","repos":"trzewiczek\/beta-vulgaris-aka-beet,trzewiczek\/beta-vulgaris-aka-beet","old_file":"lib\/panner.ck","new_file":"lib\/panner.ck","new_contents":"\/\/ due to the mono nature of the Gain UGen\n\/\/ never connect Panner to Gain based UGens\n\/\/ or Beets. Panner works best as a last\n\/\/ UGen in the effects line\npublic class Panner extends Chubgraph {\n Pan2 panner;\n OscEvent osc_event;\n\n \/\/ Constructor\n {\n inlet => panner => outlet;\n }\n\n fun void osc_event(OscEvent e) {\n e @=> osc_event;\n }\n\n \/\/ private timeloop\n fun void on() {\n while(true) {\n osc_event => now;\n\n while(osc_event.nextMsg() != 0) {\n osc_event.getFloat() => float p;\n p => panner.pan;\n }\n\n 100::ms => now;\n }\n }\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/panner.ck' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"ChucK"} {"commit":"77d061693bb0344b5fa978a86cfe649de7bf131b","subject":"Create eletronic_snare_dumb2.ck","message":"Create eletronic_snare_dumb2.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/eletronic_snare_dumb2.ck","new_file":"patches\/percussion\/eletronic_snare_dumb2.ck","new_contents":"Mix2 mout => Dyno dyno => ADSR masterEnv => dac;\nSinOsc sin1 => ADSR oscEnv1 => mout;\nSinOsc sin2 => ADSR oscEnv2 => mout;\nSinOsc detune => ADSR detuneEnv => sin2;\nSawOsc detune2 => sin1;\nNoise noise1 => LPF filt1_lp => ADSR lpfEnv => mout;\nNoise noise2 => HPF filt2_hp => ADSR hpfEnv => mout;\n2 => sin1.sync;\n2 => sin2.sync;\nmout.gain(0.5);\n\ndyno.compress();\ndyno.thresh(0.05);\ndyno.ratio(0.4);\n\nfun void trigger(float tune, int decay, int brightness, float snappy){\n\n masterEnv.set( 2::ms, (decay*17.7)::ms, 0.00, 0::ms ); \/\/a, d, s, r\n masterEnv.gain(.15);\n masterEnv.keyOn();\n\n \/\/ detune of osc\n detuneEnv.set( 2::ms, decay*2::ms, 0.0, 0::ms ); \/\/a, d, s, r\n detuneEnv.keyOn();\n 6.42 => detune.freq;\n detune.gain(56.0);\n tune => sin1.freq;\n tune => sin2.freq;\n detune2.gain(222.0);\n detune2.freq(0.16);\n \n \/\/ two oscillator setup\n\n sin1.gain(.8);\n sin2.gain(.7);\n sin1.phase(pi);\n sin2.phase(pi);\n oscEnv1.set( 2::ms, decay*0.7::ms, 0.00, 35::ms ); \/\/a, d, s, r\n oscEnv2.set( 2::ms, decay::ms, 0.00, 35::ms ); \/\/a, d, s, r\n oscEnv1.keyOn();\n oscEnv2.keyOn();\n\n \/\/ noise lowpass\n lpfEnv.set( 2::ms, (decay\/.317)::ms, 0.00, 35::ms ); \/\/a, d, s, r\n lpfEnv.keyOn();\n brightness => filt1_lp.freq;\n\n \/\/ noise lowpass\n if (snappy > 1.0) 1.0 => snappy;\n 220 => filt2_hp.freq;\n 2.7 => filt2_hp.Q;\n snappy => noise2.gain;\n hpfEnv.set( 19::ms, (decay*7.25)::ms, 0.00, 35::ms ); \/\/a, d, s, r\n hpfEnv.keyOn();\n\n \n\n \/\/ pass time.\n decay*5::ms => now;\n \/\/ oscEnv1.keyOff();\n \/\/ oscEnv2.keyOff();\n \/\/ lpfEnv.keyOff();\n \/\/ hpfEnv.keyOff();\n\n}\n\ntrigger(70.0, 90, 230, .6);\n\n1::second => now;\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/percussion\/eletronic_snare_dumb2.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"d3904e5cc140a1ffd3051e495572fe66aedea2b7","subject":"Create bassdrum_electronic_deepboom2.ck","message":"Create bassdrum_electronic_deepboom2.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electronic_deepboom2.ck","new_file":"patches\/percussion\/bassdrum_electronic_deepboom2.ck","new_contents":"\/\/ Assignment 7 drumCircleDSP\npublic class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 970, -5.98, .24, 104,-3.3, 1.8, 41.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 540::ms, 0.0, 125::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 281::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n Dyno comp => bdmast;\n comp.compress();\n SinOsc form => volE => LPF boom => PoleZero dc => comp; \n dc.blockZero(0.994);\n 132 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(.22);\n 21::samp => now;\n\n \/\/ advance time\n if (now > (start + 250::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\nKickSynC kick1;\n\nkick1.bdmast => dac;\nkick1.trigger(4.4);\n\n1::second => now;\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/percussion\/bassdrum_electronic_deepboom2.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"9b643bc810c3c7c219b9241357c932e0be80698a","subject":"Create bassdrum_electronic_deepboom3.ck","message":"Create bassdrum_electronic_deepboom3.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/bassdrum_electronic_deepboom3.ck","new_file":"patches\/percussion\/bassdrum_electronic_deepboom3.ck","new_contents":"\/\/ with some example how to wire it up.\n\npublic class KickSynC{\n\n 0.0 => float mgain;\n Gain bdmast;\n bdmast.gain(mgain);\n\n fun void trigger(float volume){\n this.bdmast.gain(volume\/3.3);\n spork ~ s_do_kick();\n }\n\n fun void s_do_kick(){\n\n CurveTable c;\n [0., 1590, -7.98, \n 0.05, 240, -.98, \n .17, 114, 0, \n .61, 54, 0, \n 1.8, 41.] => c.coefs;\n\n \/\/ frequency curve\n ADSR e => blackhole;\n e.set( 0::ms, 740::ms, 0.0, 125::ms ); \/\/a, d, s, r\n e.keyOn(1); \n\n \/\/ simple adsr\n ADSR volE;\n volE.set( 0::ms, 281::ms, 0.0, 65::ms ); \/\/a, d, s, r\n volE.keyOn();\n\n \/\/ routing.\n c => blackhole;\n Dyno comp => bdmast;\n comp.compress();\n SinOsc form => volE => LPF boom => PoleZero dc => comp; \n dc.blockZero(0.994);\n 432 => boom.freq;\n\n\n \/\/ set\n\n now => time start;\n \/\/ ready\n while (true)\n {\n c.lookup(1\/e.value()) $ int => form.freq;\n boom.Q(.26);\n 21::samp => now;\n\n \/\/ advance time\n if (now > (start + 280::ms)){\n e.keyOff();\n volE.keyOff();\n break;\n }\n }\n \n 1::second => now;\n }\n\n}\n\nKickSynC kick1;\n\nkick1.bdmast => dac;\nkick1.bdmast => NRev blunk => dac;\nblunk.gain(0.01);\nblunk.mix(0.2);\n\nfor(0 => int i; i<5; i++){\n kick1.trigger(4.4);\n 0.5::second => now;\n}\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/percussion\/bassdrum_electronic_deepboom3.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"28761413f33f288fce860a15f44ff7fc2f1bf3c6","subject":"Create clap_simple.ck","message":"Create clap_simple.ck","repos":"zeffii\/ChucKScripts","old_file":"patches\/percussion\/clap_simple.ck","new_file":"patches\/percussion\/clap_simple.ck","new_contents":"\/\/ samples.ck\nNRev ae => dac;\nae.mix(0.0152);\nae.gain(0.0212);\n\nload_sample(me.dir(-1), \"clap_01\") @=> SndBuf clapdata;\nclap_trigger();\n4::second => now;\n\nfun void clap_trigger(){\n \/\/ seg 1\n spork ~ clap_part(0.024, 0.6, rpos());\n 0.0118::second => now;\n \/\/ seg 2\n spork ~ clap_part(0.0023, 0.8, rpos());\n 0.0243::second => now;\n \/\/ seg 3\n spork ~ clap_part(0.0033, 0.7, rpos());\n 0.033::second=>now;\n \/\/ seg 4\n spork ~ clap_part(0.376, 1.0, rpos());\n 0.7::second => now; \/\/ tail\n}\n\nfun void clap_part(float fms, float force, int srpos){\n clapdata => ADSR t => HPF hpf => Gain dp => ae;\n t => HPF hpf2 => dp;\n dp.gain(22.0 * force);\n hpf.freq(1800);\n hpf2.freq(1300);\n hpf2.Q(2.3);\n\n t.set(0.2::ms, (fms)::second, 0.13, 220::ms );\n t.keyOn(1);\n srpos => clapdata.pos;\n (fms)::second => now;\n t.keyOff(1);\n}\n\nfun int rpos(){\n return Math.random2(700, 600);\n}\n\nfun SndBuf load_sample(string path, string wavname){\n \/\/ usage: load_sample(\"kick_02\") @=> SndBuf kick => dac;\n \n \/\/ turn incoming wavname into path\/wavename.wav\n SndBuf temp_buff;\n path + \"\/audio\/\" + wavname + \".wav\" => temp_buff.read;\n \n \/\/ set to end, and set gain, then return the object\n temp_buff.samples() => temp_buff.pos; \n 0.8 => temp_buff.gain; \/\/ optional default\n\n \/\/ return a reference to the new buffer object.\n return temp_buff;\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'patches\/percussion\/clap_simple.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"6fe872427f6efab69e9ce170ca7a0115951a6356","subject":"turenas prelim","message":"turenas prelim\n","repos":"gewang\/ofxChucK,gewang\/ofxChucK","old_file":"example\/bin\/data\/ck\/turenas-2.ck","new_file":"example\/bin\/data\/ck\/turenas-2.ck","new_contents":"\/\/ keyboard number\n2 => int KB_NUM;\n\/\/ light pool fade factor\n.95 => float FADE_FACTOR;\n\/\/ toggle\n0 => int LIGHT_ONOFF;\n0 => int TRAIL_ONOFF;\n0 => int POOL_ONOFF;\n\n\/\/ keyboard\nHid kb;\n\/\/ hid message\nHidMsg msg;\n\n\/\/ open\nif( !kb.openKeyboard(KB_NUM) ) me.exit();\n<<< \"KB open:\", kb.name() >>>;\nspork ~ kbf();\n\n\/\/ patch\nSndBuf L => dac.left;\nSndBuf R => dac.right;\n\n\/\/ envelope followers\nL => OnePole envL => blackhole; L => envL; 3 => envL.op;\nR => OnePole envR => blackhole; R => envR; 3 => envR.op;\n.99 => envL.pole => envR.pole;\n\n\/\/ load\nme.dir() + \"..\/audio\/turenas-L.aiff\" => L.read;\nme.dir() + \"..\/audio\/turenas-R.aiff\" => R.read;\nL.samples() => L.pos;\nR.samples() => R.pos;\n0 => L.gain => R.gain;\n\nSinOsc x => blackhole;\nSinOsc y => blackhole;\n\n1 => x.freq;\n1.5 => y.freq;\n\n\/\/ light pool\nVREntity pool[0];\n\/\/ pool index\n0 => int poolIndex;\n\/\/ number in pool\n50 => int POOL_SIZE;\n\/\/ go\nfor( int i; i < POOL_SIZE; i++ )\n{\n \/\/ construct some lights\n VR.makeEntity(\"pool\"+i, \"light\") @=> VREntity e;\n \/\/ set texture\n e.eval( \"texture texture:flare-1\" );\n e.eval( \"rotate 2\" );\n e.eval( \"num 3\" );\n \/\/ make transparent\n 0 => e.rgba.a;\n \/\/ append\n pool << e;\n \/\/ add\n VR.root().addChild( e );\n}\n\n\/\/ construct some lights\nVR.makeEntity(\"light1\", \"light\") @=> VREntity light;\n\/\/ trail (should to same root as the entity it's trailing)\nVR.makeEntity(\"trail1\", \"trail\") @=> VREntity trail;\n\n-2 => light.loc.y;\n\n\/\/ set texture\nlight.eval( \"texture texture:flare-1\" );\n\/\/ set trail length\ntrail.eval( \"length 200\" );\ntrail.eval( \"draw linestrip\" );\n\n\/\/ tall rotating red one\nlight.eval( \"rotate 1\" );\nlight.eval( \"num 5\" );\nlight.rgba.set(.25,1,.25,LIGHT_ONOFF*1);\n1 => light.sca.setAll;\n\n\/\/ color\ntrail.rgba.set(.25,1,.25,TRAIL_ONOFF*.5);\n\n\/\/ add to scene\nVR.root().addChild( light );\nVR.root().addChild( trail );\n\n\/\/ disable lights\nVR.allLightsOff();\n\nfun void kbf()\n{\n while( true )\n {\n \/\/ wait\n kb => now;\n \/\/ wait\n while( kb.recv(msg) )\n {\n if( !msg.isButtonDown() )\n continue;\n \n if( msg.ascii == 48 ) \/\/ 1\n {\n 0 => L.pos => R.pos;\n 1 => L.gain => R.gain;\n }\n \/\/ <<< \"kb:\", msg.ascii >>>;\n if( msg.ascii == 49 ) \/\/ 1\n {\n !LIGHT_ONOFF => LIGHT_ONOFF;\n LIGHT_ONOFF * 1 => light.rgba.a;\n }\n else if( msg.ascii == 50 ) \/\/ 2\n {\n !TRAIL_ONOFF => TRAIL_ONOFF;\n TRAIL_ONOFF * .5 => trail.rgba.a;\n }\n else if( msg.ascii == 51 ) \/\/ 3\n {\n !POOL_ONOFF => POOL_ONOFF;\n }\n }\n }\n}\n\n\/\/ bang detector\nfun void bangDetect()\n{\n while( true )\n {\n if( envL.last() > 0.000001 )\n {\n \/\/ add vertex\n \/\/ trail.eval( \"add\", light.loc );\n \/\/ check\n if( POOL_ONOFF )\n {\n light.loc => pool[poolIndex].loc;\n light.rgba => pool[poolIndex].rgba;\n 1 => pool[poolIndex].rgba.a;\n .5 => pool[poolIndex].sca.setAll;\n poolIndex++; POOL_SIZE %=> poolIndex;\n }\n <<< \"BANG!!\", poolIndex, now\/second >>>;\n 30::ms => now;\n }\n 5::ms => now;\n }\n}\n\n\/\/ keyboard function\nspork ~ kbf();\n\/\/ detector\nspork ~ bangDetect();\n\n\/\/ loop\nwhile( true )\n{\n 6 * x.last() => light.loc.x;\n 6 * y.last() => light.loc.y;\n \/\/ add vertex\n trail.eval( \"add\", light.loc );\n \n \/\/ update light pool\n updatePool();\n \n \/\/ synch with display\n VR.displaySync() => now;\n}\n\n\/\/ update light pool\nfun void updatePool()\n{\n for( int i; i < POOL_SIZE; i++ )\n {\n FADE_FACTOR *=> pool[i].rgba.a;\n }\n}","old_contents":"","returncode":1,"stderr":"error: pathspec 'example\/bin\/data\/ck\/turenas-2.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"8a9da1bc19b1790343597a88b9891d345b436c8d","subject":"gamut","message":"gamut\n","repos":"reidiiius\/nautiloidea","old_file":"doc\/gamut\/spectra.ck","new_file":"doc\/gamut\/spectra.ck","new_contents":"\/\/ spectra.ck \r\nTriOsc s => dac;\r\n0.5 => s.gain; \r\n\r\n 21 => int an0; 33 => int an1; 45 => int an2; 57 => int an3; 69 => int an4; 81 => int an5; 93 => int an6;105 => int an7;117 => int an8; \r\n 21 => int by0; 33 => int by1; 45 => int by2; 57 => int by3; 69 => int by4; 81 => int by5; 93 => int by6;105 => int by7; \r\n 22 => int ak0; 34 => int ak1; 46 => int ak2; 58 => int ak3; 70 => int ak4; 82 => int ak5; 94 => int ak6;106 => int ak7; \r\n 22 => int bj0; 34 => int bj1; 46 => int bj2; 58 => int bj3; 70 => int bj4; 82 => int bj5; 94 => int bj6;106 => int bj7; \r\n 23 => int bn0; 35 => int bn1; 47 => int bn2; 59 => int bn3; 71 => int bn4; 83 => int bn5; 95 => int bn6;107 => int bn7; \r\n 23 => int cj1; 35 => int cj2; 47 => int cj3; 59 => int cj4; 71 => int cj5; 83 => int cj6; 95 => int cj7;107 => int cj8; \r\n 24 => int bk0; 36 => int bk1; 48 => int bk2; 60 => int bk3; 72 => int bk4; 84 => int bk5; 96 => int bk6;108 => int bk7; \r\n 24 => int cn1; 36 => int cn2; 48 => int cn3; 60 => int cn4; 72 => int cn5; 84 => int cn6; 96 => int cn7;108 => int cn8; \r\n 25 => int ck1; 37 => int ck2; 49 => int ck3; 61 => int ck4; 73 => int ck5; 85 => int ck6; 97 => int ck7;109 => int ck8; \r\n 25 => int dj1; 37 => int dj2; 49 => int dj3; 61 => int dj4; 73 => int dj5; 85 => int dj6; 97 => int dj7;109 => int dj8; \r\n 26 => int cx1; 38 => int cx2; 50 => int cx3; 62 => int cx4; 74 => int cx5; 86 => int cx6; 98 => int cx7;110 => int cx8; \r\n 26 => int dn1; 38 => int dn2; 50 => int dn3; 62 => int dn4; 74 => int dn5; 86 => int dn6; 98 => int dn7;110 => int dn8; \r\n 26 => int ey1; 38 => int ey2; 50 => int ey3; 62 => int ey4; 74 => int ey5; 86 => int ey6; 98 => int ey7;110 => int ey8; \r\n 27 => int dk1; 39 => int dk2; 51 => int dk3; 63 => int dk4; 75 => int dk5; 87 => int dk6; 99 => int dk7;111 => int dk8; \r\n 27 => int ej1; 39 => int ej2; 51 => int ej3; 63 => int ej4; 75 => int ej5; 87 => int ej6; 99 => int ej7;111 => int ej8; \r\n 28 => int en1; 40 => int en2; 52 => int en3; 64 => int en4; 76 => int en5; 88 => int en6;100 => int en7;112 => int en8; \r\n 28 => int fj1; 40 => int fj2; 52 => int fj3; 64 => int fj4; 76 => int fj5; 88 => int fj6;100 => int fj7;112 => int fj8; \r\n 29 => int ek1; 41 => int ek2; 53 => int ek3; 65 => int ek4; 77 => int ek5; 89 => int ek6;101 => int ek7;113 => int ek8; \r\n 29 => int fn1; 41 => int fn2; 53 => int fn3; 65 => int fn4; 77 => int fn5; 89 => int fn6;101 => int fn7;113 => int fn8; \r\n 30 => int fk1; 42 => int fk2; 54 => int fk3; 66 => int fk4; 78 => int fk5; 90 => int fk6;102 => int fk7;114 => int fk8; \r\n 30 => int gj1; 42 => int gj2; 54 => int gj3; 66 => int gj4; 78 => int gj5; 90 => int gj6;102 => int gj7;114 => int gj8; \r\n 31 => int fx1; 43 => int fx2; 55 => int fx3; 67 => int fx4; 79 => int fx5; 91 => int fx6;103 => int fx7;115 => int fx8; \r\n 31 => int gn1; 43 => int gn2; 55 => int gn3; 67 => int gn4; 79 => int gn5; 91 => int gn6;103 => int gn7;115 => int gn8; \r\n 32 => int gk1; 44 => int gk2; 56 => int gk3; 68 => int gk4; 80 => int gk5; 92 => int gk6;104 => int gk7;116 => int gk8; \r\n 32 => int aj1; 44 => int aj2; 56 => int aj3; 68 => int aj4; 80 => int aj5; 92 => int aj6;104 => int aj7;116 => int aj8; \r\n\r\n144 => int tempo;\r\n 0 => int transport;\r\n\r\n[[an0,8],[ak0,8],[bn0,8],[cn1,8],[ck1,8],[dn1,8],[dk1,8],[en1,8],[fn1,8],[fk1,8],[gn1,8],[gk1,8],\r\n [an1,8],[ak1,8],[bn1,8],[cn2,8],[ck2,8],[dn2,8],[dk2,8],[en2,8],[fn2,8],[fk2,8],[gn2,8],[gk2,8],\r\n [an2,8],[ak2,8],[bn2,8],[cn3,8],[ck3,8],[dn3,8],[dk3,8],[en3,8],[fn3,8],[fk3,8],[gn3,8],[gk3,8],\r\n [an3,8],[ak3,8],[bn3,8],[cn4,8],[ck4,8],[dn4,8],[dk4,8],[en4,8],[fn4,8],[fk4,8],[gn4,8],[gk4,8],\r\n [an4,8],[ak4,8],[bn4,8],[cn5,8],[ck5,8],[dn5,8],[dk5,8],[en5,8],[fn5,8],[fk5,8],[gn5,8],[gk5,8],\r\n [an5,8],[ak5,8],[bn5,8],[cn6,8],[ck6,8],[dn6,8],[dk6,8],[en6,8],[fn6,8],[fk6,8],[gn6,8],[gk6,8],\r\n [an6,8],[ak6,8],[bn6,8],[cn7,8],[ck7,8],[dn7,8],[dk7,8],[en7,8],[fn7,8],[fk7,8],[gn7,8],[gk7,8],\r\n [an7,8],[ak7,8],[bn7,8],[cn8,8],[ck8,8],[dn8,8],[dk8,8],[en8,8],[fn8,8],[fk8,8],[gn8,8],[gk8,8],\r\n [an8,8],[aj8,8],[gn8,8],[gj8,8],[fn8,8],[en8,8],[ej8,8],[dn8,8],[dj8,8],[cn8,8],[bn7,8],[bj7,8],\r\n [an7,8],[aj7,8],[gn7,8],[gj7,8],[fn7,8],[en7,8],[ej7,8],[dn7,8],[dj7,8],[cn7,8],[bn6,8],[bj6,8],\r\n [an6,8],[aj6,8],[gn6,8],[gj6,8],[fn6,8],[en6,8],[ej6,8],[dn6,8],[dj6,8],[cn6,8],[bn5,8],[bj5,8],\r\n [an5,8],[aj5,8],[gn5,8],[gj5,8],[fn5,8],[en5,8],[ej5,8],[dn5,8],[dj5,8],[cn5,8],[bn4,8],[bj4,8],\r\n [an4,8],[aj4,8],[gn4,8],[gj4,8],[fn4,8],[en4,8],[ej4,8],[dn4,8],[dj4,8],[cn4,8],[bn3,8],[bj3,8],\r\n [an3,8],[aj3,8],[gn3,8],[gj3,8],[fn3,8],[en3,8],[ej3,8],[dn3,8],[dj3,8],[cn3,8],[bn2,8],[bj2,8],\r\n [an2,8],[aj2,8],[gn2,8],[gj2,8],[fn2,8],[en2,8],[ej2,8],[dn2,8],[dj2,8],[cn2,8],[bn1,8],[bj1,8],\r\n [an1,8],[aj1,8],[gn1,8],[gj1,8],[fn1,8],[en1,8],[ej1,8],[dn1,8],[dj1,8],[cn1,8],[bn0,8],[bj0,8]] @=> int spectra[][];\r\n\r\nwhile ( true ) \r\nfor( 0 => int i; i < spectra.cap(); i++) {\r\n Std.mtof( spectra[i][0] + transport ) => s.freq;\r\n 240000::ms \/ ( spectra[i][1] * tempo ) => now; } \r\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'doc\/gamut\/spectra.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"fd80ec693c136cdc3d1d1404c833bfd8a4ad10b0","subject":"Added abyss file","message":"Added abyss file\n","repos":"SIGMusic\/tonal-soundfield","old_file":"abyss.ck","new_file":"abyss.ck","new_contents":"SinOsc sh[10];\nLPF lp1[10];\nPRCRev rev[10];\nDyno dn[2];\nfor(0 => int x; x < 5; x++){\n\tsh[2 * x] => rev[2 * x] => lp1[2 * x] => dn[0];\n\tsh[2 * x + 1] => rev[2 * x + 1] => lp1[2 * x + 1] => dn[1];\n\t0.06 => sh[2 * x].gain;\n\t0.06 => sh[2 * x + 1].gain;\n\t40 => lp1[2 * x].freq;\n\t8 => lp1[2 * x].Q;\n\t38 => lp1[2 * x + 1].freq;\n\t8 => lp1[2 * x + 1].Q;\n\t0.1 => rev[2 * x].mix;\n\t0.1 => rev[2 * x + 1].mix;\n}\n\nfor(0 => int x; x < 2; x++){\n\t0.15 => dn[x].slopeAbove;\n\t1 => dn[x].slopeBelow;\n\t0.2 => dn[x].thresh;\n}\n\ndn[0] => dac.left;\ndn[1] => dac.right;\n\nSinOsc low => dac;\n0.15 => low.gain;\n30 => low.freq;\n\n30 => float shn;\n\nwhile(true){\n\tfor(0 => int x; x < 5; x++){\n\t\tshn * Math.pow(2, x) => Std.mtof => sh[2 * x].freq;\n\t\tshn * Math.pow(2, x) - 4 => Std.mtof => sh[2 * x + 1].freq;\n\t}\n\tshn - Math.random2f(0.001, 0.01) => shn;\n\tlow.freq() + Math.random2f(-0.05, 0.05) => low.freq;\n\t<<>>;\n\tif(shn < 15){\n\t\tshn * 2 => shn;\n\t}\n\t20::ms => now;\n}","old_contents":"","returncode":1,"stderr":"error: pathspec 'abyss.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"f6e3698b56def2a8807a5372b6bb8fb8af16eed8","subject":"Create Useful associative array example.ck","message":"Create Useful associative array example.ck\n\nThis is actually pretty cool, especially for messing with scales in a slightly more human-readable way.\r\nPlus the associative array examples in the ChucK docs really suck.","repos":"zeffii\/ChucKScripts","old_file":"demo_files\/Useful associative array example.ck","new_file":"demo_files\/Useful associative array example.ck","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'demo_files\/Useful' did not match any file(s) known to git\nerror: pathspec 'associative' did not match any file(s) known to git\nerror: pathspec 'array' did not match any file(s) known to git\nerror: pathspec 'example.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"d13ec656c7615a4fd0a2edcd457f785eb07947c9","subject":"Create dBFStoGain.ck","message":"Create dBFStoGain.ck\n\nby tildebyte.","repos":"zeffii\/ChucKScripts","old_file":"utility_functions\/dBFStoGain.ck","new_file":"utility_functions\/dBFStoGain.ck","new_contents":"\/* Allows inputting a dBFS value like a normal (sound engineer)\nperson (e.g. -6dB for a \"tame\" peak value), and getting a\nChucK \"gain\" number out (e.g. for -6dB, 0.501187).\nThe results seem to indicate that ChucK's gain, calculated\nusing the 'Std.dbtorms()' method, conforms to amplitude\n(as a ratio) as shown in the chart at the top of\nhttp:\/\/en.wikipedia.org\/wiki\/Decibel.\n\nI'd call it verified:\ndBFStoGain( x ) = y\n +3 = ~1.4\n 0 = 1 \/\/ Unity gain\n -6 = ~0.5\n-12 = ~0.25\n*\/\n\n\/\/ Not exactly rocket science >_<\nfun float dBFStoGain(float dBFS){ \n return Std.dbtorms( dBFS + 100 );\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'utility_functions\/dBFStoGain.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"} {"commit":"6270f4fb836c632c15f67fd39d30a5d2f7c8bdcf","subject":"Create to_stereo_wav.ck","message":"Create to_stereo_wav.ck","repos":"zeffii\/ChucKScripts","old_file":"wave_writer\/to_stereo_wav.ck","new_file":"wave_writer\/to_stereo_wav.ck","new_contents":"\/\/me.arg(0) => string filename;\n\/\/if( filename.length() == 0 ) \"foo.wav\" => filename;\n\ndac => Gain g => WvOut2 w => blackhole;\n\/\/\"data\/session\" => w.autoPrefix;\n\"woooot.wav\" => w.wavFilename;\n1 => w.record;\n3::second => now;\n\n\/\/ everything in between\n\n\n0 => w.record;\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'wave_writer\/to_stereo_wav.ck' did not match any file(s) known to git\n","license":"mit","lang":"ChucK"}