// title: Simple FM template // author: LFSaw // description: // Template to create a 2x3 FM Synth. There are two independent FM synths, of type `car(mod1(mod2))`. // This is intended to be a starting point for further exploration. // code: ( Ndef(\a, { var fundFreqs, ratios, levels, snd; fundFreqs = [730, 150]; ratios = [ // carrier(modulator_1(modulator_2)) [1, 3, 5], // one layer [2, 3, 9] // independent other layer ]; levels = [ [1, 0.5, 0.3], [0.8, 0.5, 0.3] ]; snd = [fundFreqs, ratios, levels].flop.collect{|v| var fundFreq, ratios, levels; #fundFreq, ratios, levels = v; // create stacked modulators // start with innermost modulator ratios = ratios.reverse; levels = levels.reverse; [ratios, levels].flop.inject(0, {|prev, vals| var ratio, level; #ratio, level = vals; // "r: % \t l: % \t %".format(ratio, level, prev).postln; SinOsc.ar((fundFreq * ratio) + (prev * fundFreq), mul: level) }).postln }; snd = Mix(snd); snd!2 }) ) Ndef(\a).edit