asmodehn / sdlut

SDL utility toolkit - A C++ wrapper arount SDL 1.2
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

Implement SDL_Audio and SDL_Mixer #20

Open asmodehn opened 10 years ago

asmodehn commented 10 years ago

This is a huge task. I am currently working on SDL_Audio wrapper. When it will be complete, I ll work on SDL_Mixer.

asmodehn commented 10 years ago

SDL_Audio was working once, but since I finished the SDL_mixer wrapper, because of the changes in interface the SDL_audio wrappers needs to evolve. This has yet to be done. However the SDL_mixer is ready for tests...

asmodehn commented 10 years ago

XorfacX: ok ive tested it and there is a pb ;) The music play too fast in ogg or wav and even faster with an mp3. After some investigations, the pb seems to be a conversion pb. In fact i don't know if the file is converted at all. Let me explain. First we init the audio which reset the mixer using this parameters (int frequency = 44100,unsigned short channels = 2,unsigned short samples = 512). But if the file we want to play isn't in 44100Hz, the bug occured. It even happen using the testAudioMusic w musicSample file that r not encoded in 44100 but 16000hz. So there 3 solutions: 1, passed parameters to initaudio(); 2, convert the file; 3, add a new method to change parameter after audio initialization. The second solution dont seems to be very good coz we're not able to set playing param elsewhere (except for channels it seems). The 3rd one dont seems very useful ? 2nd pb: i here lots of cracks, perhaps increasing the buffer size will help in this case. see http://osdl.sourceforge.net/main/documentation/rendering/SDL-audio.html#buffer ;) 3rd pb: sometimes Mix_OpenAudio(frequency,MIX_DEFAULT_FORMAT,channels, samples) simply block. I mean, there is no error returned, nor any crash, it just block. Ive read the doc and perhaps it comes from MIX_DEFAULT_FORMAT ? It can also be linked to the 1st mentioned pb (conversion not done/failed). See http://www.libsdl.org/cgi/docwiki.cgi/Mix_OpenAudio

asmodehn commented 10 years ago

XorfacX: ive updated the initAudio() function to take the parameters frequency, channels & buffer_size. it solve pb 1 & 2 when these params r set correctly. Pb 3 still there but less often.