I’ve been looking through the forum and have found a couple ways to add synths, but they seem to change the syntax. Is there any way to add synths to sonic-pi that would be use the use_synth command currently in place? I’ve been wanting to add instruments for some large projects and reworking them will be time consuming.
Not quite sure what you’re after here - are you wanting to be able to have multiple different synths playing simultaneously in your composition, or one after the other, or something else again? use_synth is designed to affect all further calls to eg play, so to play many different synths, you’d need to play one, immediately call use_synth with a different synth name, play it, call use_synth with a different name again, etc…
(Or, by ‘add synths to Sonic Pi’, do you in fact mean use synths outside of the built-in ones?)
Oh, sure.
Yes, you can definitely use use_synth as normal with external synths.
Say you had a custom synth (on macos for example, but you get the idea): /Users/luke/Desktop/my_synth.scsyndef
A typical workflow would be:
load_synthdefs "/Users/luke/Desktop" # place this at the top of your code for example
use_synth "my_synth"
play 60
The two key things to remember in this case are:
specify the name of the synth as a string, in quotes
make sure that you have the Preferences setting Audio > Synths and FX > Enable external synths and FX toggled on.
Oooh right.
Well, the synth/with_synth/use_synth/play commands all expect to play synths created with the language that Sonic Pi’s sound engine, Supercollider, provides. So the solution there is either to search the Internet for so-called Supercollider ‘SynthDefs’, or build your own. (Which I am actually in the process of doing at the moment!).
However, the alternative to this is to use Sonic Pi’s communication abilities to talk to external programs that can run other virtual synthesiser plugins.
Referring to the tutorial, sections 11 and 12 (or Sonic Pi - Tutorial and Sonic Pi - Tutorial), you’ll see that Sonic Pi has built in support for the MIDI and OSC communication protocols. Any virtual synth that accepts either of these protocols will work.
There’s probably a bunch of information floating around on the forum here about ways people have done that - search for VST, MIDI, or OSC etc. One such example which may give you an idea: Is it possible to control via Sonic Pi an instrument in Ableton?
I was looking at using sonic pi to create longer pieces (I’ve already run into the character limit problem), but I would like to be able to add different instruments to the music. For the moment, I’m looking at adding some sound font instruments to sonic pi capabilities and have found a couple examples that solve problems for very specific sound fonts. Robin Newman coded an implementation for sonatina; I was going to use his ideas to help implement newer soundfonts.
The biggest issue is finding a way to add new sounds without taking away the more advanced capabilities of sonic-pi, such as envelopes (I wasn’t completely sure if using OSC would allow me to use the envelopes). Adding a new synth would allow me to use the standard commands, like play, that would make development and the code simpler in general.
I think the original question was not really answered, and I happened to find the source of a document that answers the question.
Quote:
// ‘Tight’ integration into Sonic Pi
Integrating your synth into Sonic Pi in a tighter manner will allow you to use it without having to enable external synths and FX or explicitly load the synth path into memory beforehand. It will also enable features such as synth opt autocompletion.
However, there’s a little more involved when doing it this way. You need to add the appropriate metadata to app/server/ruby/lib/sonicpi/synths/synthinfo.rb and re-compile the app.
Lastly, as with built-in synths, you would call the synth by name with a symbol. Eg: synth :piTest .
We look forward to hearing about your synth and FX creations - have fun!//
@soprano - my original understanding of the question was ‘how can I use a custom synth with the use_synth command?’ - I then described using a custom-built synth without having to fully integrate it into Sonic Pi’s metadata. (You can use them with or without doing this).
As you have found, there are some benefits that integrating them into Sonic Pi’s metadata provides - (inclusion in the built in Synth documentation in the help panel, ability to automatically reject unsafe/invalid opt values, autocompletion of synth name and synth opt names when typing out a synth). This essentially converts them to ‘built-in’ synths - though it does require the app to be recompiled. (Which not everyone is set up or interested to do!)
Yes, actually, the quote I added complements your great answers.
The use_synth with external binary files wouldn’t show as an option when trying to choose from the available synths after hitting space.
I wonder if it would be possible for a future update to make all synths as external binary files and then if someone wanted to add new synths, they can just copy the binary files in a folder and the help will automatically add them, and the use of the synths will all be the same, whether it was added after the installation or not.
That is the plan, yes - help panel documents will potentially automatically be added for custom synths, including descriptive text, information on opts and valid ranges etc whenever the synths have had metadata/documentation strings supplied with them.
I see that the name of the tutorial page on the website now needs to end with .html - I have updated my links above to reflect this.
However, if you are more interested in building your own synths, the manual that @gordonguthrie has been building may also be of interest.
This manual is wonderfully written and answering a lot of questions I’ve had for a while that no amount of googling has been able to help with. Thank you!