使用 Python 设计滤波器抽头系数
import numpy as np
from scipy.signal import freqz, firwin
fs = 44100
nyq = fs / 2.0
taps = 99
hpf_coeffs = firwin(taps, 2800 / nyq, pass_zero=False)
freqs, resp = freqz(hpf_coeffs, 1)
sample_freqs = np.linspace(0, nyq, len(np.abs(resp)))
hpf_coeffs_quant = np.array(hpf_coeffs)
hpf_coeffs_hw = np.uint32(hpf_coeffs_quant/np.max(abs(hpf_coeffs_quant)) * 2**15 - 1)
with open("coeffs.txt", "w") as file:
for coeff in hpf_coeffs_hw:
file.write(str(coeff) + "\n")