Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Author: Sebastian Grygiel (Sebi)
- // Date: Spring 2015
- // Demo video: https://www.youtube.com/watch?v=MJAmfSJmgrA
- // See the Arduino script for more info: https://pastebin.com/yTEnXhfb
- // Ask in youtube comments, although I haven't done much with Supercollider specifically
- // Edit the COM port at the bottom of this file before use
- ( // For restarting
- SerialPort.closeAll;
- s.reboot;
- )
- ( // Synth definition
- SynthDef(\sinewave,{
- // key -> 49 == middle c
- // volume and mix take values of 0 to 1
- |key = 50, volume = 0, mix = 0.3|
- var freq = 440*pow(2,(key-49)/12);
- // Mix Sine and Saw using mix variable for ratios
- var output = Mix([SinOsc.ar(freq,0,volume*(1-mix)),Saw.ar(freq,volume*mix*0.8)]);
- Out.ar(0, [output, output]);
- }).send(s);
- )
- // Create the synth
- a = Synth(\sinewave);
- (
- // Open arduino link -- EDIT IN YOUR COM PORT PATH
- p = ArduinoSMS("/dev/ttyUSB0", 115200);
- p.action = {
- | ... msg |
- msg.postln;
- a.set(\volume, pow(min(1, msg[1]/200),2)/5);
- a.set(\mix, pow(min(1,(msg[1] - 400)/600),2)/1.5);
- a.set(\key, msg[0]);
- }
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement