I am trying to Frequency modulate a sine signal using Python. I have written the following code that should do it:
def generateSignalFM(time_vector,data):
TWO_PI = 2 * np.pi
fc = 100
b = 15
data = np.sin(TWO_PI * 1 * time_vector)
fm = np.sin(TWO_PI * (fc + b * data) * time_vector)
plot_graph2d(time_vector,data,time_vector,fm)
def plot_graph2d(t1,data1,t2,data2):
plt.plot(t2,data2)
plt.xlabel("Time(s)")
plt.ylabel("Amplitude")
plt.plot(t1,data1)
plt.legend(['FM Signal', 'Original Signal'])
plt.show()
However this is the result I'm getting back:
As you can see it does work, but it is not synchronized, the lowest frequency of the sine wave does not appear below the lowest frequency of the FM signal.
Can anyone explain why this is happening?
Tying to FM an audio file: