Hi, new here, trying to get a SuperCollider patch running on a Bela mini but its just not happening! The patch is generative and runs fine in SuperCollider. I had hoped that all it would need is a 'header' code like for Csound to run but im obviously doing something wrong.
Should i share the code here?
Any help would be incredible
Thanks in advance
p

unning supercollider on Bela involves wrapping the code you'd normally run in the Sc IDE wrapping it in a s.waitForBoot {} block.
Make sure the code inside the block runs fine in the Sc IDE if you run it all at once once the server has just startd. A common pitfall is that if it contains synthdefs or the likes, you may need a call to s.sync before you can instantiate the synths. See e.g.: this example that comes with the board : https://github.com/BelaPlatform/Bela/blob/master/examples/SuperCollider/3-analog-in/_main.scd .

Hi Giulio, thanks for the reply! i have tried this but i think its the Synthdefs that may be the issue!
I'll paste the code here incase it is easier.

(
SynthDef(\rand01,
	{ |out = 0, freq = 440, dur = 0.2, amp = 0.2, pan = 0|   // adding values here (arguement list) are defaults if they are not overwritten by pbind later.

		var env, sig, filt;
		env = EnvGen.kr(Env.perc(0.45, 4), doneAction: 2);   //envelope
		sig = LFSaw.ar(freq, 0, amp * env);    // sawtooth
		filt = LPF.ar(sig, 1200);    // low pass filter, down to 1200Hz
		pan = Pan2.ar(filt, pan);
		Out.ar(out, pan);
	};
).add;

SynthDef(\rand02,
	{ |out = 0, freq = 440, dur = 0.2, amp = 0.2, pan = 0|

		var env, sig, filt, verb;
		env = EnvGen.kr(Env.perc(0.01, 6), doneAction: 2);    // envelope
		sig = SinOsc.ar(freq, 0, amp * env);    // sine
		filt = Pan2.ar(sig * 0.2, pan);   //scaling
		verb = FreeVerb.ar(filt, mix: 0.92, room: 0.91, damp: 0.2);  // adding verb
	    Out.ar(out, sig + verb);
	};
).add;


SynthDef(\rand03,
	{ |out = 0, freq = 440, dur = 0.2, amp = 0.2, pan = 0|

		var env, sig, verb, filt;
		env = EnvGen.kr(Env.perc(0.8, 6), doneAction: 2);
		sig = LFTri.ar(freq, 0, amp * env);
		filt = LPF.ar(sig, 3000);
		pan = Pan2.ar(filt * 0.2, pan);   //scaling
		verb = FreeVerb.ar(pan, mix: 0.7, room: 0.91, damp: 0.01);
	    Out.ar(out, sig + verb);
	};
).add;


)


(
var freq01,freq02,freq03,dur01,dur02,dur03,amp01,amp02,amp03,pan01,pan02,pan03,legato;   // define variables

freq01 = Pwhite(40,60,80, 100, inf);  // pwhite-random values between low and high range. here its between 40 and 100 Hz for infinity.
freq02 = Pdup(Prand([100, 200, 500], inf), Pwhite(-1.0, 1.0));
freq03 = Pwhite(800, 3000, inf);

dur01 = Pdup(Prand([0.5, 1, 2, 3], inf), Pwhite(1, 5));   //prand random values from array.  pdup duplicates array values x times stated in pwhite.
dur02 = Pwhite(0.1, 1.2, inf);
dur03 = Pwhite(0.1, 1.4, inf);

amp01 = Pwhite(0.1, 0.2, inf);
amp02 = Pwhite(0.1, 0.3, inf);
amp03 = Pwhite(0.1, 0.2, inf);

pan01 = Pwhite(-1, 1, inf);
pan02 = Pwhite(-1, 1, inf);
pan03 = Pwhite(-1, 1, inf);

legato = Pwhite(0, 1, inf);   // legato between 0 and 100% overlap from last note


Pbind(                            // // pbind puts together synthdef and patterns-i think it plays patterns with synthdefs?.
	\instrument, \rand01,  //playing synthdef rand01
	\freq, freq01,      //read from above
	\dur, dur01,
	\amp, amp01,
	\pan, pan01
).play;

Pbind(
	\instrument, \rand02,
	\freq, freq02,
	\dur, dur02,
	\amp, amp02,
	\pan, pan02,
	\legato, legato,
).play;

Pbind(
	\instrument, \rand03,
	\freq, freq03,
	\dur, dur03,
	\amp, amp03,
	\pan, pan03,
	\legato, legato,
).play;

)

Thanks for your help

this runs:

s = Server.default;

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

s.options.blockSize = 2048;
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 2;

s.options.postln;

s.waitForBoot({
var freq01,freq02,freq03,dur01,dur02,dur03,amp01,amp02,amp03,pan01,pan02,pan03,legato;   // define variables
SynthDef(\rand01,
	{ |out = 0, freq = 440, dur = 0.2, amp = 0.2, pan = 0|   // adding values here (arguement list) are defaults if they are not overwritten by pbind later.

		var env, sig, filt;
		env = EnvGen.kr(Env.perc(0.45, 4), doneAction: 2);   //envelope
		sig = LFSaw.ar(freq, 0, amp * env);    // sawtooth
		filt = LPF.ar(sig, 1200);    // low pass filter, down to 1200Hz
		pan = Pan2.ar(filt, pan);
		Out.ar(out, pan);
	};
).add;

SynthDef(\rand02,
	{ |out = 0, freq = 440, dur = 0.2, amp = 0.2, pan = 0|

		var env, sig, filt, verb;
		env = EnvGen.kr(Env.perc(0.01, 6), doneAction: 2);    // envelope
		sig = SinOsc.ar(freq, 0, amp * env);    // sine
		filt = Pan2.ar(sig * 0.2, pan);   //scaling
		verb = FreeVerb.ar(filt, mix: 0.92, room: 0.91, damp: 0.2);  // adding verb
		Out.ar(out, sig + verb);
	};
).add;


SynthDef(\rand03,
	{ |out = 0, freq = 440, dur = 0.2, amp = 0.2, pan = 0|

		var env, sig, verb, filt;
		env = EnvGen.kr(Env.perc(0.8, 6), doneAction: 2);
		sig = LFTri.ar(freq, 0, amp * env);
		filt = LPF.ar(sig, 3000);
		pan = Pan2.ar(filt * 0.2, pan);   //scaling
		verb = FreeVerb.ar(pan, mix: 0.7, room: 0.91, damp: 0.01);
		Out.ar(out, sig + verb);
	};
).add;
	// s.sync;

freq01 = Pwhite(40,60,80, 100, inf);  // pwhite-random values between low and high range. here its between 40 and 100 Hz for infinity.
freq02 = Pdup(Prand([100, 200, 500], inf), Pwhite(-1.0, 1.0));
freq03 = Pwhite(800, 3000, inf);

dur01 = Pdup(Prand([0.5, 1, 2, 3], inf), Pwhite(1, 5));   //prand random values from array.  pdup duplicates array values x times stated in pwhite.
dur02 = Pwhite(0.1, 1.2, inf);
dur03 = Pwhite(0.1, 1.4, inf);

amp01 = Pwhite(0.1, 0.2, inf);
amp02 = Pwhite(0.1, 0.3, inf);
amp03 = Pwhite(0.1, 0.2, inf);

pan01 = Pwhite(-1, 1, inf);
pan02 = Pwhite(-1, 1, inf);
pan03 = Pwhite(-1, 1, inf);

legato = Pwhite(0, 1, inf);   // legato between 0 and 100% overlap from last note


Pbind(                            // // pbind puts together synthdef and patterns-i think it plays patterns with synthdefs?.
	\instrument, \rand01,  //playing synthdef rand01
	\freq, freq01,      //read from above
	\dur, dur01,
	\amp, amp01,
	\pan, pan01
).play;

Pbind(
	\instrument, \rand02,
	\freq, freq02,
	\dur, dur02,
	\amp, amp02,
	\pan, pan02,
	\legato, legato,
).play;

Pbind(
	\instrument, \rand03,
	\freq, freq03,
	\dur, dur03,
	\amp, amp03,
	\pan, pan03,
	\legato, legato,
).play;
});
ServerQuit.add({ 0.exit }); // quit if the button is pressed

I only really made sure that it was wrapped in s.waitForBoot as a single block (i.e.: moved the variable declaration to the top, removed the () blocks) and used the template Bela Sc code (the one you get when creating a new Sc project on Bela) for what's outside s.waitForBoot(). Even with the larger-than-usual block size I used, you'll still get dropouts, as the peak CPU usage is higher than what the board can provide. I suspect the issue is with the maximum polyphony / duration of the notes.

Ok! I'll have a look.
Thank you very much for your help