Damian Yerrick
2010-Nov-15 20:08 UTC
[Vorbis] Best practice for encoding short sound effects
A video game has several short sound effects, many of them 0.1 to 0.5 seconds in length. Which lossy audio codec is most efficient for encoding waveforms this short? I'm working on an audio framework to replace SDL_mixer, which I didn't find as flexible as I'd like. I wrote a RIFF WAVE loader, a Vorbis file loader, and a streaming Vorbis file player. But when encoding samples for testing this, I discovered that Vorbis appears to have a substantial header. I tried encoding a folder of 28 different sound effects, which take 161 KiB as a mixture of 8-bit and 16-bit mono waves at various sample rates from 12000 Hz to 32000 Hz. Converting all of them to Vorbis using OggDropXPd (libvorbis 1.3.1) at quality 3 resulted in files totaling 139 KiB. But when I resampled all of them to 32000 Hz, concatenated them into one file with about 0.1 second of silence between them, and encoded that with OggDropXPd, the result was 83 KiB for a total of roughly 11 seconds of audio. So Vorbis might not be the best choice for short sounds like these. Would CELT be any better? I see that it has "low delay"; Or should I just use, say, a 4-bit ADPCM codec like IMA, BRR, or VAG? Or is concatenation in this manner the best practice? -- Damian Yerrick
Tor-Einar Jarnbjo
2010-Nov-15 21:14 UTC
[Vorbis] Best practice for encoding short sound effects
Am 15.11.2010 21:08, schrieb Damian Yerrick> So Vorbis might not be the best choice for short sounds like these. > Would CELT be any better? I see that it has "low delay"; Or should I > just use, say, a 4-bit ADPCM codec like IMA, BRR, or VAG? Or is > concatenation in this manner the best practice?Hi Damian, Vorbis files have a header, which is usually a few kB in length and hence add a significant overhead to very short files. If you keep a separate table with sample offset and length, it is very well feasible to merge several short samples into a longer file and encode it "en bloc". You can even use proprietary Vorbis comments to embed this lookup table into the single Vorbis file, keeping all data necessary for decoding in one place. Regards, Tor