home/ atoms/ remove-above-nyquist

Harmonic synthesizers must zero out partials above the Nyquist frequency to prevent aliasing

Any sinusoidal component at or above half the sample rate (Nyquist frequency) cannot be faithfully represented and will alias — fold back into audible frequencies as spurious tones. DDSP’s remove_above_nyquist() sets the amplitude envelope to zero for all oscillators whose frequency envelope exceeds sample_rate / 2. This is applied automatically inside Harmonic.get_controls() when normalize_below_nyquist=True. At 16kHz sample rate and A4 (440 Hz), only 18 harmonics (18 × 440 = 7920 Hz < 8000 Hz Nyquist) are non-zero. The remaining harmonic distribution is then renormalized to sum to 1.

Examples

At 16kHz sample rate:

  • f0=440 Hz (A4): harmonics 1-18 valid, 19+ zeroed
  • f0=880 Hz (A5): harmonics 1-9 valid, 10+ zeroed
filtered_dist = ddsp.core.remove_above_nyquist(
    harmonic_frequencies, harmonic_distribution, sample_rate=16000)

Assessment

At 16kHz sample rate and f0=500 Hz, which harmonic numbers are zeroed out? Why must the harmonic distribution be renormalized after zeroing?

“Notice that only 18 harmonics are nonzero (sample rate 16kHz, Nyquist 8kHz, 18\*440=7920Hz) and they sum to 1.0 at all times”
corpus · ddsp-differentiable-digital-signal-processing-magenta-code-c · chunk 3