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!