Coding FM Synthesis Algorithms

I would suggest phase modulation instead of FM.

	mod = SinOsc.ar(freq * mRatio, mul: iEnv);
	car = SinOsc.ar(freq * cRatio, mod.wrap(0, 4pi)) * env * amp;

There should be no audible difference for mod -> carrier. (I had to scratch my head over that a while back, but: frequency is the derivative of phase. PM adds a sinusoid to the linearly-increasing phase. The derivative of the linear increase is a flat frequency – check – and the derivative of the sinusoidal modulator is itself a sinusoid – d/dx sin(x) = cos(x) – so phase + sin(…) and freq + cos(…) do the same thing! Simple phase modulation is mathematically equivalent to FM, just with a phase shift in the modulator that you won’t hear.)

For mod2 -> mod1 -> carrier, the frequency will drift away from center with FM, but not with PM.

mod2 -> mod1 is very likely to produce a signal with a strong DC offset. In FM, “-> car” will add this to frequency, so the average frequency applied to the carrier is biased away from true. If you add this to phase instead, then the resulting signal might have a little phase shift but the phasor representing the desired frequency continues at its own rate and you hear the frequency you wanted.

hjh