Trouble adding new Synthdefs

#1

Hello there.

I’m trying to add new synthdefs to my sonic pi environment since the built-ins aren’t suited to some of what i want to make (Industrial and EBM. They’re wonderful for dark ambient and dance-y music). I’ve found some synthdefs online which seem to adhere to the guidelines here. (or can easily be modified to fit).

They load without complaining, but when I try to play them with synth "name", note: :c1 there’s no sound. They also never stop. I managed to get sound out of this one, but it kept playing until I alt-s’d. The example synth didn’t make any sound at all.

I just cannot for the life of me make it work. I’ve even tried to super-basic example in the guidelines and I get the same result. I’m using Sonic Pi 3.1.0. on Windows 10, local install. Am i missing something obvious?

0 Likes

#2

Hi @chris.krakou,

I am not really an expert on the synth def subject but have you checked the box Allow external synth defs in the preferences (don’t know exactly the English labels because my version is in German)? Might be worth a try:

0 Likes

#3

Aah yes, I should have mentioned that I’ve enabled external synths. That’s what i meant by “loads without problems”. The problem I think I’m facing is that the synth is loaded, but not playing properly.

1 Like

#4

Hi Chris,

there are definitely a few gotchas with using your own synthdefs. SuperCollider’s notion of a ‘synth’ is extremely broad and covers any combination of it’s so-called ugens (the building blocks). This gives incredible control and flexibility but also makes it a little more difficult to share and build infrastructure around them.

Sonic Pi therefore places some constraints on external synthdefs so that they can work nicely with the environment. The following are a list of these constraints:

  • They must handle all their own arguments (for example, Sonic Pi will not convert MIDI notes like :e1 to numbers in MIDI or Hz as it has no way of knowing which units your args take).
  • They must self-terminate. This is typically achieved with an envelope which ‘frees’ the containing synth. Sonic Pi will only trigger your synths and will not manage its lifecycle beyond that.
  • They must have an argument named out_bus which is where it will feed a stereo signal.
  • They must not use any SuperCollider features that aren’t available in the audio server (the language runtime isn’t available in Sonic Pi). This means you need to compile your synthdefs and be able to use them outside of the supercollider language.

One of the main reasons Sonic Pi doesn’t (yet) have any functionality to design your own sounds internally is that this stuff is hard and needs a lot of specific knowledge. It will likely be hard to just cut and paste a synth design and get it to work seamlessly. You’ll likely need to redesign some parts to get it to fit into Sonic Pi’s architecture.

However, if you do wind up designing some new sounds - please do consider sharing them back with us here and we can even look into including them in a new release!

1 Like

#5

Thanks a ton. I’ll look into making the base example work first, and I’ll make sure to share the boilerplate I come up with.
As for the midi notes like :e1, I thought those were aliases for midi numbers that Sonic Pi fed into the synth. Are those strings or enums or something else?. As for self-termination, is there more to that than adding doneAction = 2 to the envelope?

1 Like

#6

@chris.krakou - re self-termination, that should be enough.

Re note names etc - What Sam said. Sonic Pi does not have any method of automatically knowing the format of SynthDef parameters etc - it needs to be told. Currently, Sonic Pi is informed about the ‘built in’ synths by including a bunch of extra metadata along side them. With ‘External’ synths on the other hand, there is no accompanying metadata that Sonic Pi is able to read, and as such we do not try to handle their parameters in any special way. In order to allow your new synths to handle note names or numbers, they would currently need to have some information added to this internal metadata.

This question was also raised recently on Github - there are discussions going around about a proposed improvement which would allow synth parameters to be specified in a more flexible manner. (I’m looking at working on that some time soon hopefully).

1 Like