Skip to content

audioconv64: add VADPCM beam-search refinement - #14

Open
Boxingbruin wants to merge 6 commits into
n64brew:previewfrom
Boxingbruin:vadpcm-beam-search
Open

Boxingbruin wants to merge 6 commits into
n64brew:previewfrom
Boxingbruin:vadpcm-beam-search

Conversation

@Boxingbruin

@Boxingbruin Boxingbruin commented Nov 11, 2026 •

Copy link
Copy Markdown

Improves VADPCM encoding quality by searching alternative predictor, scale, and residual choices.
Tradeoff: This method greatly increased audio compression times.

audioconv64 changes:

  • Adds beam search as an optional refinement step, enabled with vadpcm,beam=true.
  • Runs refinement after the initial VADPCM encoding step in conv_wav64.cpp, before calculating loop and seek states or packing the output.
  • Encodes stereo channels together using one thread per channel, roughly halving stereo conversion time when beam search is enabled. Falls back to sequential encoding if thread creation fails.

I believe the tradeoffs are worth it for 2bit VADPCM specifically, it reduces enough static to make it a viable choice which unlocks a lower level of compression. Not something to be done on every clean build, but something to enable for a cartridge release to save even more space. Currently to my ears, 2 bit VADPCM is not a viable choice, it contains too much static to use, this method unlocks it.

I have test results, a quality score was determined by a locally run model and noise/artifact detection that I tuned to my ear. It is not 100% accurate but pretty damn close.

Playback cost and ram usage remain the same.

quality-and-compression compression-time

You can also visually see the error rate reduction in the spectrogram:
original-vadpcm2-beam-spectrogram

Algorithm reference: https://en.wikipedia.org/wiki/Beam_search

AI Disclaimer: I used AI to help me learn VADPCM inside and out first to ensure I knew what I was doing going into this. I also had it help me write the beam search algorithm into c and interface it with VADPCM's codebook. I did writethe code by hand, only using it for assistance to make sure it was done correctly. I also used a locally run model trained on audio clip similarity and tuned it along with noise detection algorithms to match my ear as closely as I could for the quality rating.

@thekovic

Copy link
Copy Markdown
Contributor

Why is the vadpcm_beam module licensed under MPL v2? MPL is a copy-left license, albeit a so-called "weak" one with a clause regarding "distribution of a larger work". Regardless, it doesn't seem obvious to me what the ramifications are. I think it would be preferable if this PR in its entirety could be licensed under the same terms as the rest of this SDK.

@Boxingbruin

Boxingbruin commented Nov 11, 2026 •

Copy link
Copy Markdown
Author

Why is the vadpcm_beam module licensed under MPL v2?

Yep no problem, I can change that, I honestly just didn't know which licence to choose and chose the same one VADPCM runs under. Though I think Depp is going to merge beam search upstream into VADPCM anyways.

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