Skip to content

Instantly share code, notes, and snippets.

@jarmitage
Last active April 26, 2018 13:04
Show Gist options
  • Select an option

  • Save jarmitage/f4edf2131e15eb6d4b84daf53c9962c4 to your computer and use it in GitHub Desktop.

Select an option

Save jarmitage/f4edf2131e15eb6d4b84daf53c9962c4 to your computer and use it in GitHub Desktop.

/** This script exemplifies the use of SuperCollider on Bela. When a project contains a _main.scd file, sclang is started and the content of the file is executed. If you want to interact with SuperCollider running on the board from within the SuperCollider IDE on your computer, check out the 12-SuperCollider/remote examples instead. Those files also include more code examples to interface with Bela-specific UGens. */ s = Server.default;

s.options.numAnalogInChannels = 8; s.options.numAnalogOutChannels = 8; s.options.numDigitalChannels = 16;

s.options.pgaGainLeft = 4; // sets the pga gain of the left channel to 4 dB s.options.pgaGainRight = 5; // sets the pga gain of the right channel to 5 dB s.options.headphoneLevel = -8; // sets the headphone level to -8 dB s.options.speakerMuted = 0; // the speakers are not muted (so active) s.options.dacLevel = -5; // sets the gain of the dac to -5 dB s.options.adcLevel = -3; // sets the gain of the adc to -3 dB s.options.numMultiplexChannels = 0; // do not enable multiplexer channels s.options.belaPRU = 0; // select the PRU on which Bela audio will run

s.options.blockSize = 16; s.options.numInputBusChannels = 2; s.options.numOutputBusChannels = 2; s.options.numAudioBusChannels = 1024;

s.options.numBuffers = 1024 * 16; // increase this if you need to load more samples s.options.memSize = 8192 * 16; // increase this if you get "alloc failed" messages s.options.maxNodes = 1024 * 32; // increase this if you are getting drop outs and the message "too many nodes"

s.options.maxLogins = 64; // set max number of clients s.options.postln;

s.waitForBoot({ ~dirt = SuperDirt(2, s); // two output channels, increase if you want to pan across more channels // ~dirt.loadSoundFiles(); // Bela struggling with this s.sync; ~dirt.start(57120, [0, 0], (NetAddr("192.168.7.1"))); // OSCFunc.trace(true, true); // print OSC messages to the console to verify connection with Tidal });

s.latency = 0.5;

// Quarks.install("SuperDirt"); // comment out L38-42 and uncomment to initially install SuperDirt, then remove this line

@telephon
Copy link

The line s = Server.default; should be directed to the bela scsynth server. So you should write somewhere: Server.default = Server(\someName, NetAddr(your_belaIP, your_belaPort);

and the line:

~dirt.start(57120, [0, 0], (NetAddr("192.168.7.1")));

should not be the bela address, but the tidal address. You can leave out the address, too.

@jarmitage
Copy link
Author

Update

/*******************
Remotely Control the Bela

Use this project to boot scsynth on the Bela.

This script simply starts scsynth, which then waits for messages.
Use the code in the other .scd files in this project to interact with the board
from the SuperCollider IDE running on the host.

IMPORTANT: you will need to add the class files for the Bela-specific UGens to your
computer in order to run these scripts. You can get them here
https://github.com/sensestage/bela-remote

(c) 2017: Jonathan Reus, Marije Baalman, Giulio Moro, Andrew McPherson

Please note that support for SuperCollider on Bela is still experimental,
so feel free to report issues here: https://github.com/sensestage/supercollider/issues
*/

// https://gist.github.com/jarmitage/f4edf2131e15eb6d4b84daf53c9962c4

Server.default = Server(\bela, NetAddr("192.168.7.2", 57110)); // bela.local + tidal port
s = Server.default;

s.options.numAnalogInChannels = 8; // can be 2, 4 or 8
s.options.numAnalogOutChannels = 8; // can be 2, 4 or 8
s.options.numDigitalChannels = 16;
s.options.maxLogins = 4;

s.options.pgaGainLeft = 4;     // sets the gain for the left audio input to 4 dB
s.options.pgaGainRight = 5;    // sets the gain for the left audio input to 5 dB
s.options.headphoneLevel = -6; // sets the headphone level to -6 dB
s.options.speakerMuted = 0;    // enable the speaker amp
s.options.dacLevel = 0;       // sets the gain of the dac to 0 dB
s.options.adcLevel = 0;       // sets the gain of the adc to 0 dB
s.options.numMultiplexChannels = 0; // do not enable multiplexer channels

s.options.blockSize = 16;
// number of audio channels: values greater than 2 will use the first few analog
// channels as audio channels.
// Any additional analog channels will be available through the AnalogIn/Out Ugens
// e.g.:
// s.options.numInputBusChannels = 4;
// means that bus in 0/1 are the audio L/R channels and 2/3 are the analog inputs 0/1
// analog inputs 2-7 will still be available through the AnalogIn Ugen.
s.options.numInputBusChannels = 2; // Use only the L/R audio channels
s.options.numOutputBusChannels = 2; // Use only the L/R audio channels
s.options.numAudioBusChannels = 1024;

s.options.numBuffers = 1024 * 16; // increase this if you need to load more samples
s.options.memSize = 8192 * 16; // increase this if you get "alloc failed" messages
s.options.maxNodes = 1024 * 32; // increase this if you are getting drop outs and the message "too many nodes"

s.options.maxLogins = 64;  	   // set max number of clients
s.options.postln;

s.waitForBoot({
	~dirt = SuperDirt(2, s); // two output channels, increase if you want to pan across more channels
  	s.sync;
	~dirt.start(57120, [0, 0], (NetAddr("192.168.7.1")));
	// OSCFunc.trace(true, true); // print OSC messages to the console to verify connection with Tidal
});

s.latency = 0.5;

// Quarks.install("SuperDirt"); // comment out L38-42 and uncomment to initially install SuperDirt, then remove this line

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