Skip to content

Instantly share code, notes, and snippets.

@madskjeldgaard
Last active May 3, 2024 18:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madskjeldgaard/849eabca5a7201c1ad045e48463c287b to your computer and use it in GitHub Desktop.
Save madskjeldgaard/849eabca5a7201c1ad045e48463c287b to your computer and use it in GitHub Desktop.
SuperCollider to Ableton Live setup
/*
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