Running music as SDL_Mixer fragments

SDL_Mixer currently has two types of sound resources: chunks and music.

Besides the limitations of the API and supported formats, are there any reasons not to download and play music like SDL_Chunk and the channel ? (memory, speed, etc.)

+4
source share
2 answers

API is a real problem. The music APIs are designed to work with streaming compressed music, while the sound APIs are not. Again, if you manage to get it to work in your application, it will work.

+1
source

I did not look at the SDL code, but I assumed that the “chunks” are for smaller sound samples and are cached in memory, decoded completely, until the “music” is transmitted (not cached) in its entirety, but decoded and buffered as necessary, based on assumptions that it will for the most part be played from the very beginning and continuously from this point, possibly with some temporary time reset)

So, the reason is in memory. You don’t want to decode, say, 4 minutes of 16-bit stereo recording into memory, since it will consume 44100 Hz * 2 bytes * 2 channels * 4 minutes * 60 sec / min == 42336000 bytes if you try when you can decode and buffer smaller parts.

OTOH, if you have 10 MB of RAM per minute of music to waste time, and you need a processor that will be consumed on the fly ... you could probably use chunks.

+1
source

All Articles