Last active
June 21, 2016 04:28
-
-
Save hosackm/2f9670b90d5317900145 to your computer and use it in GitHub Desktop.
FIR Filter using SciPy signal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.signal as sig | |
from scipy.io.wavfile import write as write | |
from matplotlib import pyplot as plt | |
SR = 48000 | |
SECS = 10.0 | |
NSAMPS = int(SECS * SR) | |
NTAPS = 61 | |
INT_MAX = 2**15-1 | |
#lowpass = 1 freq, pass_zero=True | |
#highpass = 1 freq, pass_zero=False | |
#notch = 2 freqs, pass_zero=True | |
#bandpass = 2 freqs, pass_zero=False | |
h = sig.firwin(numtaps=NTAPS, cutoff=5000, nyq=SR/2.0, window="hamming", pass_zero=True) | |
y = sig.convolve(y, h) | |
y = np.int16(y/np.max(np.abs(2)) * INT_MAX) | |
write("5kHz_to_10kHz_bandpass_noise.wav", SR, y) | |
with open("5kHz_lp.txt", "w") as f: | |
f.write(str(h)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment