[SciPy-User] scipy.signal.remez producing odd filter effects / not producing desired effect

Matti Viljamaa mviljamaa at kapsi.fi
Mon Jul 4 09:52:42 EDT 2016


> On 04 Jul 2016, at 14:00, Matti Viljamaa <mviljamaa at kapsi.fi> wrote:
> 
> I’m trying to use the scipy.signal.remez filter design function. What I’m doing is the following (with the help of http://www.ee.iitm.ac.in/~nitin/teaching/ee5480/firdesign.html <http://www.ee.iitm.ac.in/~nitin/teaching/ee5480/firdesign.html>):
> 
> import os
> import scipy.io.wavfile
> from scipy import signal
> from pylab import * 
> 
> os.chdir("/Users/mviljamaa/Music")
> sr, data = scipy.io.wavfile.read(open(“sound.wav", 'r'))
> 
> lpf = signal.remez(21, [0, 0.05, 0.1], [1.0, .0])
> 
> # Plot the magnitude response
> w, h = signal.freqz(lpf)
> plot(w/(2*pi), 20*log10(abs(h)))
> show()
> 
> # Filtered data
> sout = signal.lfilter(lpf, 1, data)
> 
> scipy.io.wavfile.write("equalized.wav", sr, sout)
> 
>> 
> Now judging by the magnitude response of the filter lpf, it should be a lowpass of some sort (I’m not sure how to interpret the cutoff frequency yet).
> 
> The output I get is substantially gained (up to the point where it sounds distorted) and I cannot hear the lowpass filter.
> 
> What am I doing wrong?


Using a slightly modified code (from http://pastebin.com/LPEtXdzx <http://pastebin.com/LPEtXdzx>):

import os
import scipy.io.wavfile
from scipy import signal
from pylab import * 
import numpy as np

os.chdir("/Users/mviljamaa/Music")
sr, data = scipy.io.wavfile.read(open(“sound.wav", 'r'))

fs = 44100

bands = array([0,3500,4000,5500,6000,fs/2.0]) / fs
desired = [1, 0, 0]
lpf = signal.remez(513, bands, desired)

from scipy.signal import freqz
w, h = signal.freqz(lpf)
plot(w/(2*pi), 20*log10(abs(h)))
show()

sout = signal.lfilter(lpf, 1, data)

sout /=  1.05 * max(abs(sout))

scipy.io.wavfile.write("equalized.wav", sr, sout)


—

This one is able to retain the gain, but I still don’t hear any lowpass filtering.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20160704/25ea72f1/attachment.html>


More information about the SciPy-User mailing list