«Simple FM template» by LFSaw

on 02 Mar'20 14:39 in fmtemplate

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(
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
raw 819 chars (focus & ctrl+a+c to copy)
reception
comments