-
-
Save swannodette/f44d346c240c99ea91ee318a931cb116 to your computer and use it in GitHub Desktop.
Linnstrument + Supercollider
This file contains 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 characters
( | |
var notes, synths, on, off, mod, bend, touch; | |
~num_channels = 8; | |
~bend_range = 24; | |
MIDIIn.connectAll; | |
notes = Array.newClear(~num_channels); | |
synths = Array.newClear(~num_channels); | |
on = MIDIFunc.noteOn({ | vel, num, chan, src | | |
// ("on" + chan + num + vel).postln; | |
notes[chan] = num; | |
synths[chan] = Synth(\default, [\freq, num.midicps, \amp, vel * (1.0/128.0)]); | |
}); | |
off = MIDIFunc.noteOff({ | vel, num, chan, src | | |
// ("off" + chan + num + vel).postln; | |
synths[chan].release; | |
notes[chan] = nil; | |
synths[chan] = nil; | |
}); | |
mod = MIDIFunc.cc({ | val, num, chan, src | | |
// ("cc1" + chan + num + val).postln; | |
}, 1); | |
bend = MIDIFunc.bend({ | val, chan, src | | |
var bend = ~bend_range * ((val - 8192)/8192); | |
// ("bend" + chan + val).postln; | |
if (synths[chan] != nil) { | |
synths[chan].set(\freq, (notes[chan] + bend).midicps); | |
}; | |
}); | |
touch = MIDIFunc.touch({ | val, chan, src | | |
// ("touch" + chan + val).postln; | |
if (synths[chan] != nil) { | |
synths[chan].set(\amp, val * (1.0/128.0)); | |
}; | |
}); | |
q = { | |
on.free; | |
off.free; | |
mod.free; | |
bend.free; | |
touch.free; | |
} | |
) | |
q.value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment