Frequency modulation (FM)

前端 未结 3 962
别那么骄傲
别那么骄傲 2021-01-15 00:59

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

3条回答
  •  青春惊慌失措
    2021-01-15 01:29

    Unfortunately I haven't been able to get Paul's method to work but I have a working solution for FM synthesis of audio signals. I did a lot of testing in Excel and realized how to do it. Here's the algorithm

        for (i = 0; i < N; i++)     {
        // increase the frequency with increasing amlitudes (fc + fm)
        if (input[i] < input[i+1])
            out[i] =   cos(acos(input[i]) + A * sin(2 * pi * mf * i));
        else  //decrease the frequency with decreasing amplitudes (fc - fm)
            out[i] =  cos(acos(input[i]) - A *  sin(2 * pi * mf * i));
                    } 
    

    It works well but it does generate some undesirable harmonics (possibly due to rounding errors) so you may have to use some sort of a filter (a moving average might do a good job at reducing those unwanted harmonics). When applied to an audio signal, you will probably have to take the envelope of the audio and multiply it with the modulating signal so as not to apply FM on the quiet portions of the audio etc.

提交回复
热议问题