lasp/examples/example_biquadbank.py
J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F d1dea1483f
Some checks reported errors
continuous-integration/drone/push Build was killed
Updated tests
2023-01-12 20:31:55 +01:00

37 lines
816 B
Python

#!/usr/bin/python3
import numpy as np
from lasp import SeriesBiquad, AvPowerSpectra
from lasp.filter import SPLFilterDesigner
import matplotlib.pyplot as plt
from scipy.signal import sosfreqz
plt.close('all')
fs = 48000
omg = 2*np.pi*1000
filt = SPLFilterDesigner(fs).A_Sos_design()
bq = SeriesBiquad(filt.flatten())
tend=10
t = np.linspace(0, int((tend*fs)//fs), int(tend*fs), endpoint=False)
in_ = np.random.randn(t.size)
out = bq.filter(in_)
from scipy.signal import welch
nfft = 48000
freq, H1 = welch(out,
# scaling
fs=fs,nfft=nfft)
freq, H2 = welch(in_,
# scaling
fs=fs,nfft=nfft)
# plt.figure()
plt.semilogx(freq,10*np.log10(np.abs(H1/H2)))
omg, H_ex = sosfreqz(filt)
plt.semilogx(omg/(2*np.pi)*fs, 20*np.log10(np.abs(H_ex)+1e-80))