LoginSignup
3
3

More than 5 years have passed since last update.

PythonでFM変調、復調

Last updated at Posted at 2017-01-25

概要

PythonでFM変調、復調やってみた。
復調アルゴリズムは、オリジナル。

写真

figure_1.png

サンプルコード

import scipy.signal as sg
import numpy as np
import matplotlib.pyplot as plt

sample_rate = 48000.0
nsamples = 320
F_1 = 440.0
F_2 = 10000.0
F_3 = 7000.0
nyq_rate = sample_rate / 2.0
cutoff_hz = 1000.0
numtaps = 29
t = np.arange(nsamples) / sample_rate
vin = np.sin(2 * np.pi * F_1 * t) 
vfm = np.sin(2 * np.pi * F_2 * t + 6.0 * -np.cos(2 * np.pi * F_1 * t))
d = 1.0
for i in range(0, vfm.size):
   vam[i] = (vfm[i] - d) / 0.5
   d = vfm[i]
i1 = vam * np.cos(2 * np.pi * F_3 * t)
q1 = vam * np.sin(2 * np.pi * F_3 * t)
lpf = sg.firwin(numtaps, cutoff_hz / nyq_rate)
i2 = sg.lfilter(lpf, 1, i1)
q2 = sg.lfilter(lpf, 1, q1)
vo = np.sqrt(i2 * i2 + q2 * q2) 
fig = plt.figure(1)
ax = fig.add_subplot(311)
ax.plot(vin[1:300])
ax = fig.add_subplot(312)
ax.plot(vfm[1:300])
ax = fig.add_subplot(313)
ax.plot(vo[1:300])
fig.set_tight_layout(True)
plt.show()

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3