Created
December 31, 2022 22:30
-
-
Save rbnpi/9fa79ab7305e022727e20d456a8ae8f8 to your computer and use it in GitHub Desktop.
Revisions
-
rbnpi created this gist
Dec 31, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ //Sonic Pi controlled code using midi and audio input by Robin Newman // register WebMIDI navigator.requestMIDIAccess() .then(onMIDISuccess, onMIDIFailure); function onMIDISuccess(midiAccess) { console.log(midiAccess); var inputs = midiAccess.inputs; var outputs = midiAccess.outputs; for (var input of midiAccess.inputs.values()){ input.onmidimessage = getMIDIMessage; } } function onMIDIFailure() { console.log('Could not access your MIDI devices.'); } //create an array to hold our cc values and init to a normalized value var cc=Array(128).fill(0.5) getMIDIMessage = function(midiMessage) { var arr = midiMessage.data var index = arr[1] //console.log('Midi received on cc#' + index + ' value:' + arr[2]) // uncomment to monitor incoming Midi //var val = (arr[2]+1)/128.0 // normalize CC values to 0.0 - 1.0 var val = arr[2] cc[index]=val } //cc[0] controls kaleid, cc[1]-cc[3] control rgb solid mask, cc[4] controls masks alpha: can blank the screen. //audio controls colour out of voronoi voronoi(3,0.3,-0.3).color(()=>a.fft[0]*3,0.9,-0.7) .scale(0.3,1) .kaleid(()=>cc[0]) .luma(-0.8) .colorama(0.05,-0.6) .mult(solid(()=> cc[1],()=> cc[2],()=> cc[3],()=> cc[4])) .out(o0) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #sonic pi code by Robin Newman, Dec 31 2022 #drives sketch on hydra.ojack.xyz running on Chrome browser #requires Sonic Pi audio output looped back to Chrome browser use_midi_defaults channel: 1,port: "iac_driver_bus" set :kill,false midi_cc 4,1 comment do #uncomment to stop Bass note will take time to die away midi_cc 4,0 set :kill,true end use_midi_logging false use_debug false sf=2 live_loop :mid0 do stop if get(:kill) midi_cc 0, [3,6,9,5,10,15].tick # sends to control 0 a random integer between 3 and 6 sleep 0.125*sf end live_loop :mid1 do stop if get(:kill) midi_cc 1,[0,1].tick sleep 0.125*sf #rates of change of r,g,b cc all different end live_loop :mid2 do stop if get(:kill) midi_cc 2,[0,1,].tick sleep 0.25*sf end live_loop :mid3 do stop if get(:kill) midi_cc 3,[1,0,0,0,1,1,1,1].tick #mask out possibility of r,g,b cc all 0 sleep 0.5*sf end with_fx :reverb,room: 0.7,mix: 0.7 do live_loop :aud do stop if get(:kill) if tick%64 == 0 use_transpose [0,5,7,-5].tick(:tr) if look(:tr)==4 set :kill,true midi_cc 4,0 end synth :fm,note: (octs :e2,3),sustain: 10*0.125*sf,release: 64*0.125*sf,amp: 2 end density dice(2) do use_synth :tb303 k=play scale(:e2,:minor_pentatonic,num_octaves: 2).choose,release: 0.125*sf*2,cutoff: rrand_i(70,110) control k,cutoff: 100,cut_off_slide: 0.125*sf*2 end sleep [0.125*sf,0.25*sf].choose end end