How to create synth in Supercollider on Windows?

Using the info on this page I created a synth in Supercollider and defined it like this:
//----------------------------------------------------------------------------------------------
(
SynthDef(‘piTest’,
{|freq = 200, amp = 1, out_bus = 0 |
Out.ar(out_bus,
SinOsc.ar([freq,freq],0,0.5)* Line.kr(1, 0, 5, amp, doneAction: 2))}
).writeDefFile(“C:/TEST”) ;
)
//----------------------------------------------------------------------------------------------

I then run the following code in Sonic Pi:

load_synthdefs "C:/TEST/"
synth :piTest, note: 60

But I get the error:
Unknown synth :piTest

Any suggestions on where I might go wrong?

Hey @keys,

The key is in the second part of the section here: https://github.com/samaaron/sonic-pi/blob/master/SYNTH_DESIGN.md#making-the-synth-available-in-sonic-pi
In order to use the standard way of referencing the synth (eg with a symbol such as :piTest) the synth needs to be more tightly integrated into the Sonic Pi app; this involves updating some metadata in the Sonic Pi source code and recompiling the GUI.

Having said that, it is possible to refer to the synth without having to update stuff etc just by using its exact filename IIRC. I think this involves just referring to it with a string: eg synth 'piTest'. Let us know how that goes.

I’ll update that synth design document again to make this clearer. Thanks for the heads up!

1 Like

Thanks for the advise. However I tried all the commands below, but still I get the “Unknown synth” error.

load_synthdefs "C:/TEST"
#synth 'piTest', note: 60
#synth 'piTest.scsyndef', note: 60
#synth "piTest", note: 60
#synth "piTest.scsyndef", note: 60
#synth "C:/TEST/piTest.scsyndef", note: 60
#synth "C:/TEST/piTest", note: 60
#synth 'C:/TEST/piTest', note: 60

Ah. There’s one more thing I forgot to mention, sorry!
In order to allow use of synths that are not integrated into the app, there is a setting in the Sonic Pi ‘Audio’ preferences panel under ‘Synths and FX’ that must be switched on: ‘Enable external synths and FX’. I’ll make sure the synth design document mentions that too.

This thread got me looking at synth definition for the first time, using SuperColider. Quite a steep learning curve, but I’ve successfully produced one or two synths which I’ve used with my Mac.
Not fully integrating them to Sonic Pi, but pretty easy to add them in and make use of them.

Here’s one I called piBell which give a bell like tone. It responds to parameters note: amp: release: with defaults of 72, 1, 1

The synth definition is

(
SynthDef('piBell',
	{|note=72,amp=1,pan=0,attack=0.01,release= 1,out_bus = 0 |	Out.ar(out_bus,Pan2.ar(Mix(SinOsc.ar(midicps(note)*[0.5,1,1.19,1.56,2,2.51,2.66,3.01,4.1],0,amp*EnvGen.kr(Env.perc(attackTime: attack,releaseTime: release),doneAction: 2)*[0.25,1,0.8,0.5,0.9,0.4,0.3,0.6,0.1])),pan))}
).writeDefFile("/Users/rbn/Desktop/synthdefs") ;
);

obviously adjust the path for writing out the definition from SuperCollider to your synthdefs folder which should be created

I tried it out with this

load_synthdefs "/Users/rbn/Desktop/synthdefs/"

use_synth "piBell"
live_loop :ping do
  play scale(:c4,:major,num_octaves: 2).tick,release: 1,amp: 0.2,pan: rrand(-1,1)
  sleep 0.2
end

The basis of the synth was taken from this page

2 Likes

Yeah, that website is great. There’s definitely a few SynthDefs in there that I’m hoping to adapt for Sonic Pi eventually…

Fantastic! It is working fine now :smile: Thank you for the advise regarding this issue.

1 Like

I spent a few moments trying to add one of my SynthDefs to Sonic Pi. Everything is fine except for some details.

I would like to use the Sonic Pi syntax for notes : :e3 or play_chord chord(:3, :minor). Does someone knows how to do that ? I would really enjoy seing the default synths SynthDefs to achieve better integration.

EDIT : Oh, question already answered. Link : [Steal This Sound scd examples]

1 Like