Skip to content

Vocoder chunk crossfades cause audible/visible volume dips (~3–5 dB) when fixed boundaries land inside sustained vowels #39

Backlog

Description

@KiroxTV

Summary

When rendering long vocal spans (>1024 frames, e.g. quantizing or adjusting Pitch Center / Pitch Modulation across a 30–70s vocal take in v1.0.1), audible and waveform-visible volume dips (~3–5 dB) occur reliably at fixed chunk boundaries whenever a boundary lands inside a sustained vowel.

Root Cause

In Source/Audio/Vocoder.cpp (Vocoder::inferOnnxLocked):

  • Long inputs are split rigidly every step = kMaxChunkFrames - kOverlapFrames (1024 - 16 = 1008 frames, ~11.7s at 44.1 kHz / 512 hop).
  • Adjacent chunks are blended using a plain linear crossfade across the entire 16-frame (~186 ms) overlap (waveform[dstOffset + i] * (1.0f - t) + chunkWav[i] * t).
  • Because each pc_nsf_hifigan.onnx chunk starts its NSF harmonic oscillator phase independently, adjacent chunks have arbitrary phase offset at the overlap. When a fixed 1008-frame boundary happens to land inside a loud vowel and the two chunks are out of phase, they partially cancel across the 186 ms crossfade.

Reproduction & Measurement

  • Reproducible on a 30–70s vocal take whenever a sustained word crosses frame k * 1008 (e.g. 3 * 1008 = 3024 frames ≈ 35.1–35.5s). Even minimal pitch modulation triggers the same dip on the waveform at that exact timestamp, whereas reverting to the original waveform removes it.
  • Standalone test running pc_nsf_hifigan.onnx on two overlapping 1024-frame chunks of a steady 180 Hz voiced signal measured a -4.82 dB RMS dip in the overlap with the current naive linear crossfade.

Suggested Fix (Verified Locally)

  1. Silence / unvoiced-aware chunk boundaries: Instead of cutting rigidly at frameOff + 1008, search the last ~40% of each chunk for the longest/quietest unvoiced run (f0 <= 0, i.e. pause, breath, or unvoiced consonant), falling back to the lowest log-mel energy frame if a sustained note spans the entire search window. In real vocals, this keeps vowels intact inside a single chunk (0.0 dB dip).
  2. Phase-aligned compact smoothstep crossfade (fallback for voiced overlaps): If a boundary must cross voiced audio (f0 > 0), estimate the phase lag ([-300..+300] samples) via normalized cross-correlation (similar to CommitPhaseAlign.h), apply a short smoothstep crossfade (~23 ms) at the overlap center, and gently relax the lag back to 0 across the chunk body (<= ~1 cent, zero cumulative timing drift).
  3. (Related minor note in IncrementalSynthesizer.cpp): When GAME splits a single continuous vowel into 3–4 short notes (numD3PMSteps = 1) and a middle note remains neutral (0 ct) between two edited pieces, bridging short continuously-voiced gaps (e.g. <= 32 frames where voicedMask is all true and no note is explicitly dirty-neutral/reset) prevents back-to-back vocoder <-> original crossfades inside the same syllable.

Environment

  • PitchNet v1.0.1 (VST3 ARA2)
  • Windows 11, REAPER

Activity

  1. jie-chen commented on Dec 2, 2026

    @jie-chen
    Collaborator

    Thanks for the detailed report and the measurements. Your diagnosis was right, and the fix is in 37d5dbd.

    What changed. Long renders are still made in chunks, but the joins are handled differently, on both the ONNX (Windows) and Core ML (macOS) paths:

    Joins land on unvoiced frames. Each join now goes in the longest unvoiced run (pause, breath or consonant) in the last 40% of the chunk. The synthesizer now passes its voiced mask to the vocoder for this. If that window has no unvoiced frame, the join falls back to the quietest frame, as you suggested.
    The new chunk skips its start-up. It starts 8 frames before the join, so its first frames are discarded. The join also stays 8 frames clear of the end of the previous chunk. The overlap is still 16 frames, so render time doesn't change.
    Voiced joins are phase-aligned. The new chunk is delayed by up to half a period, chosen by normalized cross-correlation, so its cycles line up with the previous chunk. It's then crossfaded over about 23 ms instead of 186 ms. The delay relaxes back to zero across the chunk, so there's no cumulative timing drift. The pitch effect is well under a cent at real chunk sizes.

    Results. I tested a real phrase with chunk size forced down, so the joins landed in the middle of a sustained vowel. The worst level dip, compared with a single-pass render:

    Old joins: −5.9 / −2.8 / −8.0 dB at the three joins
    New joins: −0.9 dB at worst across the whole render (−1.4 / −1.1 dB with 64- and 128-frame chunks)

    A new unit test (VocoderChunkingTests) uses a stand-in vocoder that starts each chunk at a random phase. The old joins dip −6.7 dB there and the new ones −0.03 dB.

    Your third point (a neutral note between two edited pieces of one vowel) was covered by an earlier change, 0162ba0. In AI Resynthesis mode, an edit now re-renders its whole voiced phrase. A neutral note inside an edited phrase stays rendered rather than being spliced back to the original, so the vocoder ↔ original crossfades inside a syllable no longer happen and no gap bridging is needed.

    If you can build from master, a Pitch Center change across one of your 30–70 s takes would confirm it: listen around 35.1–35.5 s, where you heard the dip before. If anything still dips, a .pitchnet project and the timestamp would let me measure where the joins landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions