use_synth :dsaw
play 60
play(note: chord(:c3, :major))
No problem. When I write my own ones though they play single notes fine, then they crash when I play chords:
use_synth(:mysecondsynth)
play 60
play(note: chord(:c3, :major))
The error is:
Thread death!
Unable to normalise argument with key note: and value (ring <SonicPi::Chord...
So I am learning SuperCollider and figure this must be my problem and look at passing arrays as parameters and stuff. Nothing I try works. Then I read the source code to SuperCollider synths in github and they all seem to be single note synths.
I took the source of sonic-pi-rodeo renamed it an ran it and it did indeed fail with the same error on a chord.
Is there an example of how to write a SuperCollider synth that accepts chords as well as notes for me to look at?
yeah, but if the plan is to get more synths bundled with Sonic Pi using Supercollider that’s not really sustainable and if you are trying to do more complex synthesis then not having all the notes available in your SynthDef might be limiting, perhaps?
by default, Sonic Pi doesn’t mess around with any args for synths that aren’t built-in. This is because it’s impossible to know whether an arg which shares the same name, such as :note is accidental or not. If it’s accidental, it might be that the arg has completely different semantics to that of Sonic Pi’s built-in synths.
For Sonic Pi’s built-in synths there is metadata describing each of the args - their names, docs and some checker functions (checking bounds etc.). This is unfortunately not something we’ve yet worked on making easy to extend for user-defined synths.
The built-in synth metadata is stored in the synthinfo.rb files. For example, here’s a link to the :square synth:
It should be possible to hack and extend this file with metadata for your synth. However, we really should look at ways for people to bundle similar metadata with their own synths. I’m thinking a toml file or similar would be sensible for such a thing.
I am using my literate code reader so I can just write well-commented SuperCollider code and it will generate the manual pages automatically from the source
I don’t know anything unless I write it down, and I can’t remember anything from one day to the next so I might as well document my own learning SuperCollider as I go along