Multiple audio clips in a single file?

Let’s say I have dozens of tiny sound effects (footsteps, door open / close, etc.) and I don’t want to make a separate HTTP request for each individual effect file. Is there a way to combine multiple audio files into a single bundle that can be downloaded together? This is sort of like “spriting” but with audio instead of textures.

(I know this is only tangentially related to graphics, but since three.js does support audio I figured there would be folks on this board who have tackled with these issues.)

I’ve never seen this done before. Since decodeAudioData() expect an array buffer, you would need to extract the data somehow from a larger buffer. I doubt the related complexity and overhead provide enough added value.

Well, the brute force approach would be to stuff all of the little .ogg files into a big msgpack file, but I was hoping for a more elegant approach.

In terms of whether its worth the added complexity, that really depends on the nature of the app. If I was just building a demo 3d web site I wouldn’t bother, but what I am building is a commercial-quality game with a huge world where the terrain is dynamically loaded in the background as the player moves around the landscape. Keeping load times low is critical to prevent pauses in the game, or latency when interacting with objects.

The overhead of initiating an HTTP connection is substantial when you consider the cost of the TCP three-way handshake - especially when you throw HTTPS encryption into the mix. It’s much quicker to download a single 1Mb file than a hundred 10Kb files.