Skip to content

Instantly share code, notes, and snippets.

@colevscode
Created February 24, 2020 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colevscode/e0e2420013eb1eca91f344feeb7585e8 to your computer and use it in GitHub Desktop.
Save colevscode/e0e2420013eb1eca91f344feeb7585e8 to your computer and use it in GitHub Desktop.
Supercollider Startup Script for UMC404HD with Midi

( var deviceName;

deviceName = "UMC404HD 192k"; // substitute your own device here

s.reboot { // server options are only updated on reboot

// configure the sound server: here you could add hardware specific options
// see http://doc.sccode.org/Classes/ServerOptions.html
s.options.numBuffers = 1024 * 256; // increase this if you need to load more samples
s.options.memSize = 8192 * 32; // increase this if you get "alloc failed" messages
s.options.maxNodes = 1024 * 32; // increase this if you are getting drop outs / "too many nodes"
s.options.numOutputBusChannels = 4; // set this to your hardware output channel size, if necessary
s.options.numInputBusChannels = 4; // set this to your hardware output channel size, if necessary

// boot the server and start SuperDirt
s.waitForBoot {
	~dirt = SuperDirt(2, s); // two output channels, increase if you want to pan across more channels
	~dirt.loadSoundFiles; // load samples (path containing a wildcard can be passed in)
	// for example: ~dirt.loadSoundFiles("/Users/myUserName/Dirt/samples/*");
	// s.sync; // optionally: wait for samples to be read

	// Config midi
	MIDIClient.init;
	if (MIDIClient.sources.includes(deviceName), {
		~dirt.start(57120, [0, 2]); // start listening on port 57120, create two busses
		~midiOut = MIDIOut.newByName(deviceName, deviceName);
		~dirt.soundLibrary.addMIDI(\midi, ~midiOut);
		~midiOut.latency = 0.47; // Set midi latency, tweak it to line things up
	}, {
		~dirt.start(57120, [0, 0]); // start listening on port 57120, create two busses
	});

	// optional, needed for convenient access from sclang:
	(
		~d1 = ~dirt.orbits[0]; ~d2 = ~dirt.orbits[1]; ~d3 = ~dirt.orbits[2];
		~d4 = ~dirt.orbits[3]; ~d5 = ~dirt.orbits[4]; ~d6 = ~dirt.orbits[5];
		~d7 = ~dirt.orbits[6]; ~d8 = ~dirt.orbits[7]; ~d9 = ~dirt.orbits[8];
		~d10 = ~dirt.orbits[9]; ~d11 = ~dirt.orbits[10]; ~d12 = ~dirt.orbits[11];
	);

};

}; )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment