home/ atoms/ frequency-filter-fir-ddsp

DDSP's frequency_filter designs FIR filters from frequency-domain magnitude curves using IRFFT and windowing

DDSP’s frequency_filter() converts a learned magnitude envelope (in the frequency domain) into a time-domain FIR filter using the frequency sampling method: apply IRFFT to get the zero-phase impulse response, then window it with a Hann window. The windowing reduces spectral leakage and produces a causal FIR filter. FFT convolution is used for efficiency. This design allows the network to directly control the frequency-domain shape of a filter at each time frame, enabling time-varying filtering. The sinc_impulse_response() function provides an alternative low-pass design from a cutoff frequency, using a Hamming-windowed sinc function.

Examples

audio_filtered = ddsp.core.frequency_filter(
    audio,         # [batch, n_samples]
    magnitudes,    # [batch, n_frames, n_frequencies]
    window_size=257)
# Or with sinc:
ir = ddsp.core.sinc_impulse_response(cutoff_freq, window_size=512, sample_rate=16000)

Assessment

Why is a Hann window applied to the IRFFT output before using it as an FIR filter? What advantage does frequency-domain filter specification give over specifying pole/zero locations?

“def frequency_impulse_response(magnitudes: tf.Tensor, window_size: int = 0) -> tf.Tensor: """Get windowed impulse responses using the frequency sampling method.”
corpus · ddsp-differentiable-digital-signal-processing-magenta-code-c · chunk 27