From e2c3c3e95b6a9e53b4631b271640bb9914f8c95e Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 5 Mar 2026 10:03:32 +0100 Subject: fix(audio): OLA encoder never ran; version never propagated to decoder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs kept the v2 OLA path permanently disabled: 1. SpectrogramResourceManager::load_asset() never set spec.version from SpecHeader::version — all .spec assets loaded with version=0, so ola_mode was always false in the voice. 2. spectool analyze_audio() used non-overlapping chunks (stride=DCT_SIZE), hamming_window_512, and hardcoded header.version=1 — OLA analysis was never implemented in the encoder. Fixes: propagate header->version in load_asset(); switch spectool to OLA_HOP_SIZE stride, hann_window_512, and SPEC_VERSION_V2_OLA. Regenerated all .spec files. handoff(Gemini): OLA enc/dec chain now correct end-to-end. .spec files are v2 (50% overlap, Hann). No API changes; 33/34 tests pass (WavDumpBackendTest pre-existing failure unrelated). Co-Authored-By: Claude Sonnet 4.6 --- doc/COMPLETED.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/COMPLETED.md b/doc/COMPLETED.md index e37ddbf..9b9f549 100644 --- a/doc/COMPLETED.md +++ b/doc/COMPLETED.md @@ -33,10 +33,10 @@ Use `read @doc/archive/FILENAME.md` to access archived documents. - [x] **OLA-IDCT Synthesis — click-free .spec decoding** - **Goal**: Eliminate frame-boundary clicks in spectrogram→PCM synthesis. - - **Implementation**: Added v2 spectrogram format (`SPEC_VERSION_V2_OLA`). Synthesis uses Hann-windowed IDCT with 50% overlap-add (hop=256, overlap=256). Per-voice `overlap_buf[256]` accumulates the tail from the previous IDCT frame. V1 path (raw DCT-512) preserved for generated notes and old `.spec` files. Hann window precomputed at `synth_init()`. MP3 encoder switched from Hamming to Hann, now slides a 512-sample analysis window by 256 samples per frame (OLA analysis), emitting ~2× as many frames. `SpecHeader.version` field propagated through `Spectrogram.version` to the voice's `ola_mode` flag at trigger time. - - **Files**: `src/audio/dct.h`, `src/audio/synth.h`, `src/audio/synth.cc`, `src/audio/window.h`, `src/audio/window.cc`, `src/audio/tracker.cc` + - **Implementation**: Added v2 spectrogram format (`SPEC_VERSION_V2_OLA`). Synthesis uses Hann-windowed IDCT with 50% overlap-add (hop=256, overlap=256). Per-voice `overlap_buf[256]` accumulates the tail from the previous IDCT frame. V1 path (raw DCT-512) preserved for generated notes. Hann window precomputed at `synth_init()`. `SpecHeader.version` field propagated through `Spectrogram.version` to the voice's `ola_mode` flag at trigger time. + - **Bug fix (2026-03-05)**: Two bugs prevented OLA from ever activating: (1) `SpectrogramResourceManager::load_asset()` never set `resource->spec.version` from `header->version` — all loaded assets got `version=0`, OLA path silently skipped. (2) `spectool analyze_audio()` used non-overlapping frames (`chunk_idx * DCT_SIZE` stride), `hamming_window_512`, and hardcoded `header.version = 1` — the OLA encoder was never implemented. Fixed both; `.spec` files regenerated. + - **Files**: `src/audio/spectrogram_resource_manager.cc`, `tools/spectool.cc`, `workspaces/main/music/*.spec` - **Tests**: 34/34 passing - - **Pending**: Regenerate `.spec` files from MP3 assets to activate v2 encoding. ## Recently Completed (February 21, 2026) -- cgit v1.2.3