Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Convolving impulse response of a 1st order low pass filter produces extremely distorted audio

$
0
0

I am working on designing a filter bank for an analog audio project and I want to test different filter topologies (bessel, chebyshev, butterworth etc.) before moving on to circuit simulation. I'm starting with a simple example to test the process - a first order low pass filter. I load my wav file (3 seconds long), take the ifft of the laplace transform of the filter, then I convolve it with the audio.

I haven't attached the audio, but I can assure you no low-pass filtering is happening. The audio is extremely distorted.

import numpy as npfrom scipy.io import wavfileimport sounddevice as sdsamplerate, data = wavfile.read('sample.wav')w0 = 2*np.pi*170 #cutoff freq (1/RC)f = np.fft.fftfreq(len(data), d = 1/samplerate)transfer = w0 / (1j*2*np.pi*f + w0)impulse_response = np.fft.ifft(transfer)filtered_signal = np.convolve(data, impulse_response, mode='same')filtered_signal = filtered_signal.realsd.play(filtered_signal.real, samplerate)sd.wait()

P.S. I recently discovered that LTSpice accepts wav files as signal inputs, and I got the expected result when I implemented this with a voltage source, resistor, and capacitor. Can't quite figure out the DSP here.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>