{
   "labels" : [
      "fm",
      "code fork",
      "template"
   ],
   "is_private" : null,
   "id" : "1-5cV",
   "code" : "(\r\nNdef(\\a, {\r\n\tvar fundFreqs, ratios, fmLevels, adLevels, partials, snd;\r\n\tfundFreqs = [730, 150];\r\n\tratios = [\r\n\t\t[1, 3, 5], // three vals\r\n\t\t[2, 3, 9]\r\n\t];\r\n\tfmLevels = [\r\n\t\t[0.5, 0.3], // interrelation between two modulators, hence 2 vals\r\n\t\t[0.7, 0.3]\r\n\t];\r\n\tadLevels = [\r\n\t\t[1, 0.2, 0.6],\r\n\t\t[0.9, 0.3, 0.3]\r\n\t];\r\n\t\r\n\tsnd = [fundFreqs, ratios, fmLevels, adLevels].flop.collect{|v|\r\n\t\tvar fundFreq, ratios, fmLevels, adLevels, partials, prevFMLevels;\r\n\t\t#fundFreq, ratios, fmLevels, adLevels = v;\r\n\t\t\r\n\t\t// create stacked modulators\r\n\t\t// start with innermost modulator\r\n\t\tratios = ratios.reverse;\r\n\t\tprevFMLevels = (fmLevels ++ [1]).reverse;\r\n\t\t\r\n\t\tpartials = [ratios, prevFMLevels, adLevels].flop.inject([0], {|prev, vals|\r\n\t\t\tvar ratio, prevFMLevel;\r\n\t\t\t#ratio, prevFMLevel = vals;\r\n\t\t\t\r\n\t\t\t// \"r: % \\t l: % \\t %\".format(ratio, fmLevel, prev).postln;\r\n\t\t\t[SinOsc.ar((fundFreq * ratio) + (prev.first * fundFreq * prevFMLevel))] ++ prev\r\n\t\t});\r\n\t\t\r\n\t\tpartials = partials[0..(partials.size-2)]; // now should have [car, mod1, mod2, ...]\r\n\t\tpartials = partials * adLevels;\r\n\t};\r\n\tsnd = Mix(snd.flat);\r\n\t\r\n\tsnd!2\r\n})\r\n)\r\n\r\nNdef(\\a).edit",
   "author" : "LFSaw",
   "name" : "Simple FM template with additive mixing of modulators",
   "description" : "Template to create a 2x3 FM Synth. There are two independent FM synths, of type `car(mod1(mod2))`.\r\nall carriers and modulators are collected together and are mixed to the output according to `adLevels`.\r\nThis is intended to be a starting point for further exploration.",
   "ancestor_list" : [
      "1-5cU"
   ]
}
