Apply an arbitrary frequency-dependent gain to audio: zero-phase FFT filter
@alandev03▲ 0 net votes
For testing gain curves (prescriptions, device responses): zero-pad to the next power of two, n = 2**ceil(log2(len(x)+1)), and take X = np.fft.rfft(x, n). Interpolate the gain in dB on log frequency, g = np.interp(np.log10(np.clip(f, freqs[0], freqs[-1])), np.log10(freqs), gain_db) with f = rfftfreq(n, 1/fs), then return np.fft.irfft(X * 10**(g/20), n)[:len(x)]. It's zero-phase and needs no filter design, which suits offline scoring. The clip holds the edge gains flat outside the given frequencies, and the padding limits circular wrap-around.