Skip to content

feat(optimize): add opt-in --flac to re-encode wav sounds - #910

Merged
francisdb merged 1 commit into
francisdb:mainfrom
gitfool:feat/optimize-flac
Oct 4, 2026
Merged

francisdb merged 1 commit into
francisdb:mainfrom
gitfool:feat/optimize-flac

Conversation

@gitfool

@gitfool gitfool commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Builds on the FLAC conversion that landed in vpin (fix::wavs_to_flac, francisdb/vpin#545) and surfaces it in optimize.

optimize --flac re-encodes a table's PCM WAV sounds as lossless FLAC, on top of the lossless image and font fixes it already runs. It is a separate flag because, unlike the image fixes, it changes which builds play the table: only vpinball with the miniaudio sound engine (10.8.1 and later) decodes FLAC, and the sound manager accepts .flac since vpinball/vpinball#4066, so an older build would play the table without those sounds. Without the flag, optimize behaves exactly as before.

apply now takes an Options struct, the report gains the converted sounds and the WAVs left alone (with the reason), and format_outcome prints a line per sound with the bytes before and after. Bumps the vpin dependency to 0.37.4 for fix::wavs_to_flac.

Tested end to end against four real tables: each shrank substantially (Aliens 498 -> 201 MB, Guardians 508 -> 359 MB, Batman 66 308 -> 240 MB, America's Most Haunted 348 -> 290 MB), the output re-reads and verifies, and the converted sounds play back correctly in vpinball with the miniaudio engine.

optimize --flac re-encodes a table's PCM WAV sounds as lossless FLAC,
on top of the lossless image and font fixes it already runs. It is a
separate flag because, unlike the image fixes, it changes which builds
play the table: only vpinball with the miniaudio sound engine (10.8.1
and later) decodes FLAC, so an older build would play without those
sounds. Without the flag optimize behaves as before.

apply takes an Options struct, the report gains the converted sounds
and the wavs left alone with their reason, and format_outcome prints a
line per sound with the bytes before and after. Bumps vpin to 0.37.4
for fix::wavs_to_flac.
@francisdb
francisdb merged commit 92ee593 into francisdb:main Oct 4, 2026
4 checks passed
@francisdb

Copy link
Copy Markdown
Owner

I did not expect that much size reduction 👍

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.

2 participants