Good SynthDef writing for co34pt_LiveCode
If you're going to be writing SynthDefs for Patterns in the format I use in these guides and in my sets, there's a few rules to ensure that things run reasonably smoothly.
freq and frequency
The carrier of a main frequency of a SynthDef should have the argument name
freq - this will allow for the use of scales, tunings and detuning within Pattern arguments, from the documentation:
detunedFreq actual "pitch" of a synth, determined by: freq + detune; freq is determined by: (midinote + ctranspose).midicps * harmonic; midinote is determined by: (note + gtranspose + root)/stepsPerOctave * octave * 12; note is determined by: (degree + mtranspose).degreeToKey(scale, stepsPerOctave)
There are a couple of instances where you can't use
freq as the actual frequency, so in which case, use Pkey to reroute the frequency argument like this:
//where x is the frequency argument Pbind(\instrument,\foo,\x,Pkey(\freq),\scale,Scale.minor,\degree,Pseq([4,5,6],inf))
Each SynthDef should have an argument
out in its
Out.ar. I always leave it as 0, but it can be used to handle effects routing. I don't know why, but if it doesn't have it, it won't work inside of ProxySpace.
Envelopes will be automatically triggered as part of patterns, on the assumption that the trigger of any envelope is set to
1. It's also much easier to use envelopes where it does not need a release trigger. I generally use
Env.linen. It's also important to use a
doneAction which will free the synth once the envelope has completed.