Filtering by taking FFT, zeroing bins, and inverse FFT is a bad idea, as discussed here.
But what about:
take a STFT, (i.e. multiply the input signal by moving window function, and take FFT)
zero some bins in the STFT matrix
inverse STFT (using overlap-add)
I've tried it, it's not bad, but I've got horizontal ripples in the spectrogram:
from perso import stft from scipy.io import wavfile import numpy as np sr, x = wavfile.read('in.wav') s = stft.stft(x, fftsize = 4096) s[:,0:11] = 0 s[:,13:] = 0 z = stft.istft(s) z = np.float32(z) wavfile.write('out.wav', sr, z)
Important note: why do I absolutely want to do the filter in the frequency domain? Because I want to do a filter that evolves over time... With a STFT, it would be super simple to make the filter evolve for each time frame...
for k in s.shape: s[k,f(k):0] = 0 # where f(k) varies over time (k)
Is there a way to make a good-working STFT filtering in the frequency domain?