I\'m trying to Frequency modulate an audio signal. I can successfuly FM a sine wave (the carrier) with another sine wave (the modulator) by using the following equation y=co
You can think of FM as just dynamically varying the playback rate, where the variation in playback rate is proportional to your modulating signal. So for normal playback your playback rate is the same as the sample rate, Fs
. For an FM version of your audio signal you playback rate will be Fs * (1 + A * f(t))
, where A
is the modulation amplitude and f(t)
is the modulating signal. To implement this you will need to maintain a phase accumulator with a real and a fractional component, and then update the phase accumulator according to the current (modulated) sample rate. Use the integer part of the phase accumulator to determine the sample index, n
and use the fractional part to enable you to interpolate, e.g. between samples n
and n + 1
.
Not that this is very similar to wavetable synthesis, except that your waveform table is a sampled sound instead of a periodic waveform. See e.g. this question on dsp.stackexchange.com for further info.