Diff from Simple FM template by LFSaw (02 Mar'20 14:39) to Simple FM template with additive mixing of modulators by LFSaw (02 Mar'20 15:05)

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))`. all carriers and modulators are collected together and are mixed to the output according to `adLevels`. This is intended to be a starting point for further exploration.
code
( Ndef(\a, { var fundFreqs, ratios, fmLevels, adLevels, partials, snd; fundFreqs = [730, 150]; ratios = [ // carrier(modulator_1(modulator_2)) [1, 3, 5], // onthree lvayerls [2, 3, 9] ]; fmLevels = [ [0.5, 0.3], // indteprrelationd between two modulators, hernce l2 vayerls [0.7, 0.3] ]; ladLevels = [ [1, 0.52, 0.36], [0.89, 0.53, 0.3] ]; snd = [fundFreqs, ratios, fmLevels, adLevels].flop.collect{|v| var fundFreq, ratios, fmLevels, adLevels, partials, prevFMLevels; #fundFreq, ratios, fmLevels, adLevels = v; // create stacked modulators // start with innermost modulator ratios = ratios.reverse; lprevFMLevels = l(fmLevels ++ [1]).reverse; partials = [ratios, prevFMLevels, adLevels].flop.inject([0], {|prev, vals| var ratio, lprevFMLevel; #ratio, lprevFMLevel = vals; // "r: % \t l: % \t %".format(ratio, lfmLevel, prev).postln; [SinOsc.ar((fundFreq * ratio) + (prev.first * fundFreq), mul:* lprevFMLevel))] ++ prev }); partials = partials[0..(partials.size-2)]; // now should have [car, mod1, mod2, ...] partialns = partials * adLevels; }; snd = Mix(snd.flat); snd!2 }) ) Ndef(\a).edit
category tags
fm, code fork, template
ancestors
1-5cU