Strange results from my FM synthesis algorithm
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 !).