Skip to content

fix(packs): every FLAC conversion is read back, and installing again repairs the damaged ones - #44

Merged
devlato merged 1 commit into
mainfrom
fix/flac-conversion
Oct 20, 2026
Merged

devlato merged 1 commit into
mainfrom
fix/flac-conversion

Conversation

@devlato

@devlato devlato commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Packs that ship WAV are stored as FLAC after download. On some 24-bit audio, flacenc 0.5.1 misjudges what a subframe will cost and writes frames of megabytes that decode to noise or not at all. Two notes of VCSL's harmonica (a default pack) come out at 438 MB and 339 MB from 600 KB WAVs; Apple's decoder refuses them, and symphonia reads 196,085 samples instead of 200,181, 146,927 of them wrong. It is deterministic: the same file encodes the same way on one thread.

What changes:

  • transcode_flac reads each conversion back with symphonia (the decoder playback uses) and compares it with the samples. When the FLAC is larger than the samples it holds, or does not read back exactly, the file is encoded again verbatim (raw samples inside FLAC), which always works.
  • Installing a pack converts again any FLAC that claudius wrote and that is larger than the audio its header says it holds, so earlier installs heal with claudius-packs install --defaults (noted in the changelog).

Neither of flacenc's settings avoids it on its own: exact bit counting fixes the harmonica (571 KB) but blows up a synthetic tone of 40 harmonics at 784 Hz (168 MB from 132 KB), which the defaults encode at 2x its size.

How I checked:

  • New tests: loud 24-bit harmonics never produce a FLAC larger than their samples and read back exactly; a conversion padded out the way flacenc's broken frames are is recognised, a WAV or a missing file is not.
  • A VCSL install made with today's main had 13 such files. Installing again with this branch found them, re-downloaded 8.5 MB and converted them anew; the folder is 138 MB, about what a healthy install takes (144 MB). The repaired harmonica G4 decodes identically to its WAV with claudius' decoder and with afconvert.
  • cargo xtask ci passes.

@devlato
devlato enabled auto-merge (squash) October 20, 2026 01:07
@devlato
devlato merged commit b946329 into main Oct 20, 2026
27 checks passed
@devlato
devlato deleted the fix/flac-conversion branch October 20, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant