Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Simple Frequency Modulation SynthDef
name
code content
// This is a very basic example, I know, but I found it was hard /// to find basic synthdefs when I was getting started. SynthDef(\fm, { |freq=200, atk=0.01, decay=0.3, sustain=0.4, rel=0.1 carratio=1,modratio=1, modindex=1, amp=0.2, gate=1, outBus=0| var env = EnvGen.kr(Env.adsr(atk, decay, sustain, rel), gate, doneAction:2); var mod = SinOsc.ar(freq * modratio); var car = SinOsc.ar(freq * carratio + (1 + (mod *modindex)), 0) * amp * env; Out.ar(0, car ! 2); }).add; ) // how to start the synth with inital values ~fmSynth = Synth.new(\fm, [\freq, 220]); // how to alter a synth in real time ~fmSynth.set(\freq, 260); // how to liberate the synth ~fmSynth.free; /* design notes input args are mostly self explainatory: freq controls pitch of carrier and modulator wave modratio scales the freq of modulator wave carratio scalese the freq of carrier wave (useful for creating different ratios of FM - carrier:modulator - ex: 1:3, 3:5, 1:9, etc ) atk, delay, sustain, rel are enelope controls for a typical ADSR envelope modindex controls the intensity of the modulation, bigger values for modindex create more numerous sidebands amp is the amplitude (volume) on the line with Out.ar(0, car ! 2) car ! 2 splits the signal in two in order to be stereo */
code description
This is a very basic example, I know, but I found it was hard to find basic synthdefs when I was getting started. input args are mostly self explainatory: freq controls pitch of carrier and modulator wave modratio scales the freq of modulator wave carratio scalese the freq of carrier wave (useful for creating different ratios of FM - carrier:modulator - ex: 1:3, 3:5, 1:9, etc ) atk, delay, sustain, rel are enelope controls for a typical ADSR envelope modindex controls the intensity of the modulation, bigger values for modindex create more numerous sidebands amp is the amplitude (volume) on the line with Out.ar(0, car ! 2) car ! 2 splits the signal in two in order to be stereo
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change