[…]
So I try to put the sequence of : SDL_LoadWAV(), SDL_OpenAudio(),
SDL_PauseAudio(0),… in a new thread. But when SDL_OpenAudio() or
SDL_OpenAudioDevice() is called from the new thread (different from the main
thread) they fail with the error message of not possible to open audio
device.
[…]
The SDL audio API is a very low level one, and isn’t intended to be
used like this. You’re supposed to call SDL_OpenAudio() once,
initialize some kind of “audio engine” (load sounds, create structures
to manage the number of voices or similar that you need etc), activate
it all with SDL_PauseAudio(0), and then have this “engine” generate a
continuous stream of audio, until it’s time to close.
If you want to do it the hard way; rolling your own, and learning a
bit about audio processing in the process, my ancient "simplemixer"
example might be a starting point:
http://olofson.net/examples.html
There are probably other, better ones out there. (Maybe I should write
a proper one…?) This one doesn’t even do resampling, which is pretty
much required in any real application. Also, this is for SDL 1.2, so
it might need some changes for 2.0.
The easiest way is probably to use an existing mixer/engine of some
sort. The most obvious alternative would be SDL_mixer:
http://www.libsdl.org/projects/SDL_mixer/
SDL_sound may also be of interest. Originally, this dealt only with
loading/decoding of audio files, but there is/was apparently a mixer
in the works as well for 2.0, though I don’t know what happened with
that:
http://www.icculus.org/SDL_sound/
Of course, there is Audiality 2 that I'm working on now, and Audiality
"1" (the sound engine of Kobo Deluxe), but although either would do
the job, the old one is abandoned, the new one would still need
SDL_sound or something to load anything but raw audio files (I suppose
you could use SDL_LoadWAV() with it...) - and both are kind of odd,
complex beasts, more focused on synthesis, procedural sound and stuff.
A2 will become nicer, get authoring tools and stuff eventually, but as
it is, you'll need to learn a small scripting language to do anything
much with it. :-)
On Wed, Nov 20, 2013 at 5:58 PM, alabouza wrote:
–
//David Olofson - Consultant, Developer, Artist, Open Source Advocate
.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://consulting.olofson.net http://olofsonarcade.com |
’---------------------------------------------------------------------’