I am quite the noob as far as audio programming goes, but it seems I want to do something that is not covered by any tutorial that I have seen and I was wandering if someone can point me to the right direction.
Any SDL audio tutorial has a step where you are supposed to use a load_wav() function of some kind to preload the sounds.
Now what if I don’t want to do this but instead need to provide an on-the-fly generated stream to the audio device?
Lets assume that I am making a movie player that plays movies with more then one audio stream. I would need to
A. Extract the audio info form the movie file (in my own code).
B. Mix the audio streams on-the-fly (in my own code).
C. Feed the audio buffer with my on-the-fly mixed stream.
Now, assume that I know exactly how to do A and B.
I just can’t figure out how to begin writing code do do step C. Either I misunderstand the tutorials or you cant’t just feed the buffer with your own data.
Can anybody point me in the right direction?
Thanks for reading, and thanks in advance for responding.
Btw, I use C++ and am currently coding with Eclipse@Linux.-----------
Edit: Ok I’m rephrasing the question. Asking the same thing, but coming at it from a different angle.
The SDL_MixAudio documentation that is here has this to say:
Note: Do not use this function for mixing together more than two streams of sample data. The output from repeated application of this function may be distorted by clipping, because there is no accumulator with greater range than the input (not to mention this being an inefficient way of doing it). Use mixing functions from SDL_mixer, OpenAL, or write your own mixer instead
Fine, so I want to make my own mixer then. What API should I code the mixer against so libSDL can play the result?
And another way to ask the same question.
ScummVM uses libSDL to play sound on Windows/Linux/Mac.
You can see the source-tree here.
They do call SDL_OpenAudio
They do call SDL_AudioSpec
They do NOT call SDL_GetAudioStatus
They do NOT call SDL_LoadWAV
They do NOT call SDL_MixAudio
They do NOT call SDL_LockAudio
They do NOT call Mix_OpenAudio
So how do they exactly manage to play sound? What is the core mechanism? Where do they tell the audio device to swap buffers?
As mentioned above, I would be very grateful for any insight that anyone can give me.