SDL_mixer

Hi All,

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.

Thanks!

Andre de Leiradella

Hi All,

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. :slight_smile:

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

i try the loopwave.c coming as an example of use of SDL_mixer.
and read one wav file i have on my system.

though it work i heard a very distinctive whistle.
do you see any reason for this ?

i have w2000, SDL1.2.1, SDL_mixer1.2.0

i try the loopwave.c coming as an example of use of SDL_mixer.
and read one wav file i have on my system.

though it work i heard a very distinctive whistle.
do you see any reason for this ?

i have w2000, SDL1.2.1, SDL_mixer1.2.0

Please privately email me the wavfile, and I’ll take a look to see if it’s
a platform-specific bug or an SDL_mixer issue.

Thanks,
–ryan.

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.

Thanks

Cliff Benoist
@kernel_at_seul.org

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.

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.

This was asked a few days ago. Please search the mailing list archive.
(http://www.libsdl.org/pipermail/sdl/2001-November/thread.html#40203)

-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.

Hey guys,

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.

Thanx in advance,

Thibaut

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.)

–ryan.

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:

http://www.libsdl.org/intro/usingsound.html

This shows a call-back mechanism, but I think is shows the same principle
(SDL_LockAudio and SDL_UnlockAudio)…

Kind regards,

Patrick.

On Wed, 5 Jun 2002 09:28:47 0200 “Marc Le
Glanaer”<the_pecheur at libertysurf.fr> wrote.

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)?

–ryan.

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(’

the code compiler fine in M$ windows

//Perra

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?

I’m using SDL 1.2.5, SDL_mixer 1.2.4 & BeOS 5.0.3

thanks a lot,
Mahmoud Al Gammal

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?

Regards,

Pieter Hulshoff

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

Can I play 2 music files together?

If I use “playmus” sample I can play as many music files I want but with loading 2 different processes.

If I can play together 2 music files with SDL_mixer, how can I handle every file (for pausing, resuming, volume etc)

Is there a function like Mix_LoadMUS but with SDLRWops parameter???

Can I play 2 music files together?

No, you probably want to look at SDL_sound and use that to load the music
files and then mix them with the rest of your sound effects.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment