I’ve been playing with SDL_mixer and noticed that there was a small delay
between the call to Mix_PlayChannelTimed() and the actual sound being played
through the speakers. I was initializing the mixer with
Mix_OpenAudio(22050,AUDIO_S16,2,4096).
I changed the chunk size to 1024 and now the delay is hardly noticeble (512
didn’t work). I’d like to know if anyone has made tests with this value and
came up with a “good” value for this parameter and if anyone knows how this
impact the performace of my application as a whole.
I’ve been playing with SDL_mixer and noticed that there was a small delay
between the call to Mix_PlayChannelTimed() and the actual sound being played
through the speakers. I was initializing the mixer with
Mix_OpenAudio(22050,AUDIO_S16,2,4096).
I changed the chunk size to 1024 and now the delay is hardly noticeble (512
didn’t work). I’d like to know if anyone has made tests with this value and
came up with a “good” value for this parameter and if anyone knows how this
impact the performace of my application as a whole.
1024 is usually a good value.
See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment
I have been looking at the SDL_mixer library and wondering if there is a
document on how to use it. I am having trouble understanding what its
capabilities are. If anyone know or has a document please email me
directly.
I have been looking at the SDL_mixer library and wondering if there is a
document on how to use it. I am having trouble understanding what its
capabilities are. If anyone know or has a document please email me
directly.
the SDL_mixer.h header file is very well documented. that and a small
example like playwav should be all you need to get going. granted, in
some ways that’s not the same as real documentation, but it shouldn’t be
difficult to follow.
-JakobOn Tue, Nov 20, 2001 at 10:32:18AM -0500, kernel at seul.org wrote:
I have been looking at the SDL_mixer library and wondering if there is a
document on how to use it. I am having trouble understanding what its
capabilities are. If anyone know or has a document please email me
directly.
I have a problem. I would like to know if Mix_FreeChunk(…) works with
Mix_CloseAudio() and SDL_QuitSubSystem(SDL_Audio) called before.
In my game I want to give the possibility to turn off the sound.
So I call
Mix_HaltChannel() for every channel,
then
Mix_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
In the channel_complete_callback(int chan)
I call then
Mix_FreeChunk(…)
But this function is a callback function and supposely in another thread. So
it is possible
that first Mix_CloseAudio() and SDL_QuitSubSystem(…) are called before.
If then Mix_FreeChunk(…) does not work, the program creates big memory
leaks,
which I certainly do not want to have.
In the channel_complete_callback(int chan) I call then
Mix_FreeChunk(…) But this function is a callback function and
supposely in another thread. So it is possible that first
Mix_CloseAudio() and SDL_QuitSubSystem(…) are called before. If then
Mix_FreeChunk(…) does not work, the program creates big memory leaks,
which I certainly do not want to have.
When you call Mix_CloseAudio(), it halts all the playing channels and
calls their “done” callbacks before returning. It is safe to call
Mix_FreeChunk() in these callbacks. You do not need to explicitly call
Mix_HaltChannel() before Mix_CloseAudio(), since it will be done for you.
(As an aside, by the luck of the current code’s design, you CAN call
Mix_FreeChunk after even SDL_Quit(), and it will work, but you should NOT
rely on this behaviour.)
I wonder what could stop sound (a several ms stop)when
calling Mix_PlayChannel.
I’m trying to modify the lib so that I can use it as a
sequencer without stop between the samples played.
I works correctly on one channel but when I try to launch
a second channel, a short stop occurs.
Does anyone knows what happens ?
regards.--------------
Profitez de l’offre exceptionnelle Tiscali !
"Internet Gratuit le Jour"
Cliquez ici, http://register.tiscali.fr/forfaits_ls/
Offre soumise ? conditions.
I’m just starting with SDL_Mixer myself, so I’m not certain. But I think
that when adding a buffer to the mixer, it does a lock on the sound-system
so it can safely copy data. So the playing pauses between a call to lock and
unlock. This is how it works when playing sound without the mixer, as shown
on this page:
I wonder what could stop sound (a several ms stop)when
calling Mix_PlayChannel.
What platform are you using (Linux, win32, Mac?), and how did you call
Mix_OpenAudio()? Are you sure the stop occurs with Mix_PlayChannel(), or
is it some other code that runs when you’ve got multiple sounds to play?
What version are you using of SDL, SDL_mixer? What format sounds are you
playing (WAV, MP3, etc)?
When I i try to compile my SDL project with SDL_mixer in Linux (RedHat and
SuSE 8.0) i got this error msg
In file included from main.cpp:32:
/usr/include/SDL/SDL_mixer.h:61: syntax error before (' ... ... /usr/include/SDL/SDL_mixer.h:567: syntax error before(’
When I i try to compile my SDL project with SDL_mixer in Linux (RedHat and
SuSE 8.0) i got this error msg
In file included from main.cpp:32:
/usr/include/SDL/SDL_mixer.h:61: syntax error before (' ... ... /usr/include/SDL/SDL_mixer.h:567: syntax error before(’
You need to install SDL 1.2.5 development files.
See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment
Hi…
I have some problems with SDL_mixer, so here we go:
The following sequence of invokations causes a segmentation fault & SDL
parachute to deploy:
SDL_Init();
SDL_SetVideoMode();
Mix_OpenAudio();
Mix_LoadMUS();
Mix_PlayMusic() [invoked from another thread]
Mix_CloseAudio();
I know that it’s not recommended to call library functions from separate
threads but there’s a need that Mix_PlayMusic() be called from its own
thread…so is that why i get this behaviour?
also, the quality of SDL_mixer output is not very good, especially when I
play sounds while music is playing, even at 44.1 kHz & 16-bit…any hints?
Mix_PlayMusic() [invoked from another thread]
Mix_CloseAudio();
I may be out on a limb here (as I’ve just written my first SDL program this
weekend:), but is it wise to close the audio while the music is playing?
Shouldn’t you stop the music first before freeing up the memory reserved for
the audio file?
Hi…
I have some problems with SDL_mixer, so here we go:
The following sequence of invokations causes a segmentation fault & SDL
parachute to deploy:
SDL_Init();
SDL_SetVideoMode();
Mix_OpenAudio();
Mix_LoadMUS();
Mix_PlayMusic() [invoked from another thread]
Mix_CloseAudio();
I know that it’s not recommended to call library functions from separate
threads but there’s a need that Mix_PlayMusic() be called from its own
thread…so is that why i get this behaviour?
Yes, probably. Have you tried running it in a debugger to see where it crashes?
also, the quality of SDL_mixer output is not very good, especially when I
play sounds while music is playing, even at 44.1 kHz & 16-bit…any hints?
Use a larger output buffer. 4096 samples should be fine.
See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment