summaryrefslogtreecommitdiff
path: root/doc/COMPLETED.md
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-03-05 22:49:48 +0100
committerskal <pascal.massimino@gmail.com>2026-03-05 22:49:48 +0100
commitdb6fbf8b8eae8b96d129ac673cbf11d67926996a (patch)
tree97d28da56a77c17f5583a9342a77cb065b25f31f /doc/COMPLETED.md
parentb7fc4aa9a6bd15ce9780d46a425971d523c10b92 (diff)
fix(audio): correct OLA synthesis and extract shared ola_encode/ola_decode
- Remove erroneous Hann synthesis window from synth.cc (g_hann * tmp[j]). Hann analysis at 50% overlap satisfies w[n]+w[n+H]=1, so rectangular synthesis gives perfect reconstruction; applying Hann twice was wrong. - Extract ola_encode()/ola_decode()/ola_num_frames() into src/audio/ola.h+cc. spectool and test_wav_roundtrip now use the shared functions. synth.cc lazy-decode path stays inlined (see TODO for future refactor). - Drop dead <atomic> include and g_hann array from synth.cc. - Drop dead window.h include from spectool.cc. - Update PROJECT_CONTEXT.md, COMPLETED.md, TODO.md to reflect correct analysis-only Hann window and new ola.h API. handoff(Gemini): OLA synthesis bug fixed + ola.h factorized. synth.cc lazy-decode still inline (TODO item added). 34/35 tests pass; WavDumpBackendTest failure is pre-existing and unrelated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'doc/COMPLETED.md')
-rw-r--r--doc/COMPLETED.md6
1 files changed, 4 insertions, 2 deletions
diff --git a/doc/COMPLETED.md b/doc/COMPLETED.md
index 9b9f549..d72591f 100644
--- a/doc/COMPLETED.md
+++ b/doc/COMPLETED.md
@@ -33,9 +33,11 @@ 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. Hann window precomputed at `synth_init()`. `SpecHeader.version` field propagated through `Spectrogram.version` to the voice's `ola_mode` flag at trigger time.
+ - **Implementation**: Added v2 spectrogram format (`SPEC_VERSION_V2_OLA`). Analysis uses Hann window (FDCT), synthesis uses IDCT-OLA with rectangular synthesis window (no synthesis window — Hann at 50% overlap satisfies w[n]+w[n+H]=1, giving perfect reconstruction). 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. `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`
+ - **Bug fix (2026-03-05)**: `synth.cc` incorrectly applied a Hann synthesis window post-IDCT (`tmp[j] *= g_hann[j]`), effectively squaring the window and preventing perfect reconstruction. Removed synthesis window and dead `g_hann` array. `spectool` and the test were already correct.
+ - **Refactor (2026-03-05)**: Extracted `ola_encode()` / `ola_decode()` / `ola_num_frames()` into `src/audio/ola.h` + `ola.cc`. `spectool` and `test_wav_roundtrip` now use the shared functions; `synth.cc` inline path unchanged (lazy frame decode; see TODO).
+ - **Files**: `src/audio/spectrogram_resource_manager.cc`, `tools/spectool.cc`, `src/audio/synth.cc`, `src/audio/ola.h`, `src/audio/ola.cc`, `workspaces/main/music/*.spec`
- **Tests**: 34/34 passing
## Recently Completed (February 21, 2026)