Last active
November 28, 2024 09:44
-
-
Save madskjeldgaard/849eabca5a7201c1ad045e48463c287b to your computer and use it in GitHub Desktop.
SuperCollider to Ableton Live setup
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 characters
/* | |
This small patch is an example of how to nicely send midi to Ableton Live from SuperCollider. | |
It includes how to set up Ableton Link (don't forget to press the "LINK" button in Live) and play a pattern using Link and midi. | |
It is assumed that you do this on MacOS and you have created a midi driver called "IAC Driver". | |
*/ | |
( | |
Server.local.waitForBoot{ | |
//------------------------------------------------------------------// | |
// setup midi // | |
//------------------------------------------------------------------// | |
MIDIClient.init; | |
Server.local.sync; | |
~midiout = MIDIOut.newByName("IAC Driver", "Bus 1").latency_(Server.default.latency); | |
// Kill all notes on cmd period (to avoid hanging notes) | |
~cmdPeriodAdded = ~cmdPeriodAdded ? false; | |
~cmdPeriodAdded.not.if{ | |
CmdPeriod.add({ | |
16.do{|chan| | |
~midiout.allNotesOff(chan) | |
} | |
}); | |
~cmdPeriodAdded = true; | |
}; | |
//------------------------------------------------------------------// | |
// Link // | |
//------------------------------------------------------------------// | |
~linktempo = 2; | |
// Tempo in both SC and Live will change if you go ~linkClock.tempo_(0.5); | |
~linkClock = LinkClock(~linktempo).latency_(Server.default.latency); | |
~linkCmdPeriodAdded = ~linkCmdPeriodAdded ? false; | |
~linkCmdPeriodAdded.not.if{ | |
CmdPeriod.add({ | |
~linkClock = LinkClock(~linktempo).latency_(Server.default.latency); | |
}); | |
~linkCmdPeriodAdded = true; | |
}; | |
//------------------------------------------------------------------// | |
// Play pattern // | |
//------------------------------------------------------------------// | |
Server.local.sync; | |
// Play some Steve Reich-ey patterns | |
Pbind( | |
\type, \midi, | |
\midicmd, \noteOn, | |
\midiout, ~midiout, | |
\octave, Pstep([4,5],Pxrand([32,16], inf),inf), | |
\degree, | |
Ptuple([ | |
Pshuf((0..4) ++ [Rest()], inf), | |
Pshuf(5+(0..4)++ [Rest()], inf), | |
Pshuf(5-(0..4)++ [Rest()], inf), | |
], inf), | |
\chan, 0, | |
\legato, 0.5, | |
\amp, Pexprand(0.5,0.6), | |
\dur, 0.25 | |
).play( | |
clock: ~linkClock, | |
quant: 4 | |
) | |
}; | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment