Strange results from my FM synthesis algorithm It seems that I haven't studied enough about FM Synthesis.
My current algorithm looks like this:

modulator = sin( 2 * pi * fm_freq * i/sample_rate )
carrier = sin( 2 * pi * ( freq + modulator ) * i/sample_rate )


Instead of generating one stable waveform, it generates a sound warping from a pure sine wave to something awfully distorted. What am I doing wrong?
It should be more like this:

modulator = A_mod * sin(2 * pi * fm_freq * i / sample_rate)

carrier = sin (2 * pi * (freq * (1 + modulator)) * i / sample_rate)


The two main changes are:


the modulation signal needs a scale factor (A_mod) which determines the amplitude of the FM - typically A_mod &lt;&lt; 1
the carrier frequency needs to be multiplied by (1 + modulator) rather than just modulator, since it needs to be centered about freq with a deviation of +/- A_mod * freq (in your version the centre frequency is zero and your instantaneous frequency is varying between +/- freq !).