Modifying and compiling synthdefs

Overtone seemed less daunting as I’m already familiar with Clojure, but I’ve had a bit of a look into SuperCollider and managed to get a basic synthdef working, with most of the parameters hardcoded for now, but with the tune parameter set from the fractional part of the note. I’ve loaded it into Sonic Pi with load_synthdefs, and it can play fractional tuning!

My synthdef so far looks like:

(
SynthDef(\testPiano, {|
	note = 52, decay = 0, release = 1,
	velcurve = 0.8, stereo_width = 0,
	out_bus = 0 |

	var n = round(note, 1);
	var tune = note - n + 0.5;
	var snd = MdaPiano.ar(freq: n.midicps, tune: tune, gate: 1, vel: 64,
		decay: decay, release: release, hard: 0.5, velhard: 0.8,
		muffle: 0.8, velmuff: 0.8, velcurve: velcurve, stereo: stereo_width,
		random: 0, stretch: 0, sustain: 0.1);
	Out.ar(out_bus, snd)}
).writeDefFile("/output/path/")
)

I still need to implement the rest of the functionality from the built-in piano synth, but it’s looking promising :smiley:. I don’t suppose you’ve got an example I could use as a reference for how things like the varlag, clipping/scaling, envelope etc. would be done in SuperCollider?

Thanks a lot for your help!
Emlyn

1 Like