SDL_Mixer

I’m trying to play an mp3, or an ogg file with
SDL_Mixer(); when i use the Win32 binary file from the
site, neither file type opens (they return -1). When i
dl the MSVC++ 6 source and compile it, the new mixer
lib and dlls wont work (Mix_OpenAudio(44100,
AUDIO_S16, 2, 1024) returns -1). What could i be doing wrong?__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

Hello!

I’d like to use the SDL_Mixer library but I’m experiencing one
severe problem. This problem has already been discussed here, but
the proposed solution did not work for me.

When I call Mix_PlayChannel() it takes some time (about half a
second) until the sound actually comes out of the speakers.
I tried to initialize audio with Mix_OpenAudio(22050, AUDIO_S16, 2, 1024)
instead of Mix_OpenAudio(44100, AUDIO_S16, 2, 4096), which I used before,
but there’s still a half-a-second gap between the function call and the
sound to be actually played.

As a matter of fact I realized that other applications using SDL_Mixer do
not have this kind of problem. So I tried some source code from others.
Their binaries played the sound as it should be. But the binaries compiled
on my system had the same time-gap problem. I even tried to use their version
of SDL_Mixer.dll - no change.

Now I’m out of ideas and need help!

I’m using the MinGW compiler under WinXP and the latest version of SDL and SDL_Mixer.

Has anyone any hints on what might cause this problem?

Thanx in advance!
BiG OSHi============================================

The difference between ingenuity and
insanity is that ingenuity has its limits…

============================================
BiG OSHi
BiG_OSHi at RonnzWorld.com

http://BiG-OSHi.net
http://RonnzWorld.com

I’m using the MinGW compiler under WinXP and the latest version of SDL and SDL_Mixer.

It sounds like you don’t have the DirectX development librarie installed.
Grab them from:
http://www.libsdl.org/extras/win32/mingw32/README.txt

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

Hello Sam!

Thank you very much!

This indeed was the problem. Everything works fine now! :slight_smile:

Grettings
BiG OSHi

================== received mail start =====================

I’m using the MinGW compiler under WinXP and the latest version of SDL and SDL_Mixer.

It sounds like you don’t have the DirectX development librarie installed.
Grab them from:
http://www.libsdl.org/extras/win32/mingw32/README.txt

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


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

================== received mail end =====================

I’m rewriting the sound system for StepMania (www.stepmania.com), partly
to get rid of Bass (as it’s not GPL-compatible). As a music game, its
sound requirements are a bit higher than most games; these are things that I
couldn’t find answered in the documentation. (They’re in rough order of
importance.)

  1. The most important thing is sync: we need to be able to query the exact
    position in a playing sound (eg. to robustly keep sync through any skips
    and so on).

  2. The other most important thing is latency. We’ll probably be adding
    BeatMania support soon, which keys sounds to button presses; there must
    be zero perceptible lag. I’ve seen people here asking about latency
    problems–one in ME, one in Linux–but I’ve seen no resolution; any
    clues here?

  3. We need to be able to mix a lot of sounds. In theory, a BM song
    could need to mix about 20 samples at a time. (In practice, it’s
    usually not more than 5-8, I’d say, but it needs to not blow up or
    affect framerate in worst-case scenarios.) I don’t know how optimized
    the mixer is, or if it’s capable of taking advantage of hardware mixing?

  4. Precise seeking in all file formats. Is Mix_SetMusicPosition
    accurate (including for VBR MP3s), or does it approximate?

Another question about Mix_SetMusicPosition: what about WAV? (It seems
obvious, but the documentation seems to say that it only works with MOD,
OGG and MP3.)

  1. Buffering. We’ll often be loading over a hundred samples, and since
    we need low latency, they’ll need to buffer at load time. Faster
    systems may only need to buffer a small bit (for faster initial loads),
    perhaps a second or two; slower systems (and those running the game off
    a CD, perhaps) might need to buffer a much larger amount. Is there any
    way to control this?

  2. Frequency-space data. Some wishlist items need access to it (eg. to
    display a voiceprint in the editor); we could DCT the data manually, but
    that’s expensive, and a waste since most sounds come from OGG and MP3,
    which have DCT data as an intermediate step in decoding anyway. It’d be
    useful to have access to that data.

So, is there any chance SDL_mixer is capable of this, or could be with a
reasonable amount of work? (I’m willing to work on it, of course, but
only if it’s a reasonable amount of work, or it’ll defeat the purpose
of using a library. :slight_smile: Failing that, any suggestions for cross-platform
(GPL-compatible) sound libraries would be appreciated.–
Glenn Maynard

Hi Glenn

  1. As long as you keep the buffer size small you will have good latency.
    The windib audio implementation in win32 has latency issues, but the directx
    audio imp seems fine. (BTW Sam L, thanks for the directx mingw fix)

  2. Buffering: as mentioned above, the buffers have to be kept small for
    good latency. If you are reading your audio from a cd-rom, you should
    maintain an auxillary buffer yourself, likely managed by a separate thread.

  3. DCT: Not too familiar with DCT. If it is the same complexity as FFT
    then today’s processors can do it without blinking and you shouldn’t think
    of it being expensive. Look at www.fftw.org for a nice FFT implemenation (I
    don’t know if this helps you for DFT).

Cheers,
Dan.> ----- Original Message -----

From: g_sdl@zewt.org (Glenn Maynard)
To:
Sent: Wednesday, November 06, 2002 10:57 PM
Subject: [SDL] SDL_Mixer

I’m rewriting the sound system for StepMania (www.stepmania.com), partly
to get rid of Bass (as it’s not GPL-compatible). As a music game, its
sound requirements are a bit higher than most games; these are things that
I
couldn’t find answered in the documentation. (They’re in rough order of
importance.)

  1. The most important thing is sync: we need to be able to query the exact
    position in a playing sound (eg. to robustly keep sync through any skips
    and so on).

  2. The other most important thing is latency. We’ll probably be adding
    BeatMania support soon, which keys sounds to button presses; there must
    be zero perceptible lag. I’ve seen people here asking about latency
    problems–one in ME, one in Linux–but I’ve seen no resolution; any
    clues here?

  3. We need to be able to mix a lot of sounds. In theory, a BM song
    could need to mix about 20 samples at a time. (In practice, it’s
    usually not more than 5-8, I’d say, but it needs to not blow up or
    affect framerate in worst-case scenarios.) I don’t know how optimized
    the mixer is, or if it’s capable of taking advantage of hardware mixing?

  4. Precise seeking in all file formats. Is Mix_SetMusicPosition
    accurate (including for VBR MP3s), or does it approximate?

Another question about Mix_SetMusicPosition: what about WAV? (It seems
obvious, but the documentation seems to say that it only works with MOD,
OGG and MP3.)

  1. Buffering. We’ll often be loading over a hundred samples, and since
    we need low latency, they’ll need to buffer at load time. Faster
    systems may only need to buffer a small bit (for faster initial loads),
    perhaps a second or two; slower systems (and those running the game off
    a CD, perhaps) might need to buffer a much larger amount. Is there any
    way to control this?

  2. Frequency-space data. Some wishlist items need access to it (eg. to
    display a voiceprint in the editor); we could DCT the data manually, but
    that’s expensive, and a waste since most sounds come from OGG and MP3,
    which have DCT data as an intermediate step in decoding anyway. It’d be
    useful to have access to that data.

So, is there any chance SDL_mixer is capable of this, or could be with a
reasonable amount of work? (I’m willing to work on it, of course, but
only if it’s a reasonable amount of work, or it’ll defeat the purpose
of using a library. :slight_smile: Failing that, any suggestions for cross-platform
(GPL-compatible) sound libraries would be appreciated.


Glenn Maynard


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Actually, FFT is what I meant; I got my transforms mixed up. Oops.

Erg. More fundamental problems: it looks like SDL_mixer can’t stream
larger samples from disk, and can’t load MP3/OGGs as samples. That renders
it mostly useless here. (The latter is a fairly major gap …)

I suppose I have to write my own sound mixing, then. I don’t suppose
there are any libraries that’ll at least abstract MP3, OGG and WAV
reading, so I don’t have to learn how a bunch of utility libraries work?On Thu, Nov 07, 2002 at 08:03:54AM -0600, Daniel Goertzen wrote:

  1. DCT: Not too familiar with DCT. If it is the same complexity as FFT
    then today’s processors can do it without blinking and you shouldn’t think
    of it being expensive. Look at www.fftw.org for a nice FFT implemenation (I
    don’t know if this helps you for DFT).


Glenn Maynard

2 : If you want portability you can’t use a too small buffer size, as it
heavily depends on the underlying system (sound drivers + os + libraries

  • …). Very low latency sounds (10ms and less) are only achieved with
    special drivers on good hardware (high end sound cards), because a
    normal driver will also buffer sounds.

Maybe you can write a little “test” loop that will run at the begining
and adjust the buffer size until it sees the sound doesn’t skip (it sees
there is no skip when the size requested by the feedback function
stabilizes, ie if you are asked a huge block by the feedback function
this is not a good sign).

3 : I posted a patch for SDL that mixes sound using MMX some days ago,
it gives a ~8 times speedup. You might want to use it, depending on your
platform.

6 : why don’t you use the mpglig sources ? It’s protable and faster than
smpeg, especially if you backport the assembler part to it. Then you can
extract the band info during the processing.

why not use openal for the audio. very cool and works great.

MichaelOn Thu, 2002-11-07 at 15:50, user at domain.invalid wrote:

2 : If you want portability you can’t use a too small buffer size, as it
heavily depends on the underlying system (sound drivers + os + libraries

  • …). Very low latency sounds (10ms and less) are only achieved with
    special drivers on good hardware (high end sound cards), because a
    normal driver will also buffer sounds.

Maybe you can write a little “test” loop that will run at the begining
and adjust the buffer size until it sees the sound doesn’t skip (it sees
there is no skip when the size requested by the feedback function
stabilizes, ie if you are asked a huge block by the feedback function
this is not a good sign).

3 : I posted a patch for SDL that mixes sound using MMX some days ago,
it gives a ~8 times speedup. You might want to use it, depending on your
platform.

6 : why don’t you use the mpglig sources ? It’s protable and faster than
smpeg, especially if you backport the assembler part to it. Then you can
extract the band info during the processing.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

yeah OpenAL seems promising (:> ----- Original Message -----

From: mehollifield@magnalinea.com (Michael Hollifield)
To:
Sent: Thursday, November 07, 2002 1:17 PM
Subject: Re: [SDL] SDL_Mixer

why not use openal for the audio. very cool and works great.

Michael

On Thu, 2002-11-07 at 15:50, user at domain.invalid wrote:

2 : If you want portability you can’t use a too small buffer size, as it
heavily depends on the underlying system (sound drivers + os + libraries

  • …). Very low latency sounds (10ms and less) are only achieved with
    special drivers on good hardware (high end sound cards), because a
    normal driver will also buffer sounds.

Maybe you can write a little “test” loop that will run at the begining
and adjust the buffer size until it sees the sound doesn’t skip (it sees
there is no skip when the size requested by the feedback function
stabilizes, ie if you are asked a huge block by the feedback function
this is not a good sign).

3 : I posted a patch for SDL that mixes sound using MMX some days ago,
it gives a ~8 times speedup. You might want to use it, depending on your
platform.

6 : why don’t you use the mpglig sources ? It’s protable and faster than
smpeg, especially if you backport the assembler part to it. Then you can
extract the band info during the processing.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I suppose I have to write my own sound mixing, then. I don’t suppose
there are any libraries that’ll at least abstract MP3, OGG and WAV
reading, so I don’t have to learn how a bunch of utility libraries work?
You can have a look at FMOD library, it’s not LGPL but it is cross
platform and has all the features you requested, I’v been using it
myself instead of SDL_Mixer because of strange gaps and glitches when
playing MP3 files at 44100KHz and very hard CPU usage for mixing, it
isn’t optimized…hope someone one day will optimize it :slight_smile:

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20021108/aa0e1bb1/attachment.pgp

FMOD isn’t GPL-compatible, so it can’t be used with GPL-licensed
projects any more than Bass can.On Fri, Nov 08, 2002 at 02:09:03PM +0300, Paolo (cTh) Gavocanov wrote:

I suppose I have to write my own sound mixing, then. I don’t suppose
there are any libraries that’ll at least abstract MP3, OGG and WAV
reading, so I don’t have to learn how a bunch of utility libraries work?
You can have a look at FMOD library, it’s not LGPL but it is cross
platform and has all the features you requested, I’v been using it
myself instead of SDL_Mixer because of strange gaps and glitches when
playing MP3 files at 44100KHz and very hard CPU usage for mixing, it
isn’t optimized…hope someone one day will optimize it :slight_smile:


Glenn Maynard

Erg. More fundamental problems: it looks like SDL_mixer can’t stream
larger samples from disk, and can’t load MP3/OGGs as samples. That renders
it mostly useless here. (The latter is a fairly major gap …)

Take a look at SDL_sound, it was designed to address exactly this problem.

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

I thought with LGPL products all you needed to do was:

"1. Include the source code for the version of SDL that you link
with, as well as the full source or object code to your application so
that the user can relink your application, "

If you have a commercial library that when used with the application and
SDL source allows the user to relink the application, does this comply
with LGPL?
Just curious about what constitutes object code,
RobertOn Fri, 2002-11-08 at 13:24, Glenn Maynard wrote:

On Fri, Nov 08, 2002 at 02:09:03PM +0300, Paolo (cTh) Gavocanov wrote:

I suppose I have to write my own sound mixing, then. I don’t suppose
there are any libraries that’ll at least abstract MP3, OGG and WAV
reading, so I don’t have to learn how a bunch of utility libraries work?
You can have a look at FMOD library, it’s not LGPL but it is cross
platform and has all the features you requested, I’v been using it
myself instead of SDL_Mixer because of strange gaps and glitches when
playing MP3 files at 44100KHz and very hard CPU usage for mixing, it
isn’t optimized…hope someone one day will optimize it :slight_smile:

FMOD isn’t GPL-compatible, so it can’t be used with GPL-licensed
projects any more than Bass can.


Glenn Maynard


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

INALA (I’m Not A Legal Attorney), but…

It depends how you are linking against the libraries.

If the libaries that fall under the LGPL are linked against dynamically, for
instance DLLs under windows, you do not need include the source code to your
own application.

If you link statically against the libraries that fall under the LGPL - ie:
the LGPL’s code is linked into your own code - then you need to provide your
source or object code so a user can relink your application.

The reason the LGPL was created was to allow commercial, closed source
software to make use of GPL’d libraries. For example, I can write a program
that dynamically links against GLIBC under linux because it falls under the
LGPL. If it weren’t for this, every program linked against GLIBC would have
to provide its source.

Sorry if I havn’t been able to make this clear.

Ty> ----- Original Message -----

From: robert@littlebitlost.com (Robert Diel)
To:
Sent: Friday, November 08, 2002 3:43 PM
Subject: Re: [SDL] SDL_Mixer

I thought with LGPL products all you needed to do was:

"1. Include the source code for the version of SDL that you link
with, as well as the full source or object code to your application so
that the user can relink your application, "

If you have a commercial library that when used with the application and
SDL source allows the user to relink the application, does this comply
with LGPL?
Just curious about what constitutes object code,
Robert

On Fri, 2002-11-08 at 13:24, Glenn Maynard wrote:

On Fri, Nov 08, 2002 at 02:09:03PM +0300, Paolo (cTh) Gavocanov wrote:

I suppose I have to write my own sound mixing, then. I don’t suppose
there are any libraries that’ll at least abstract MP3, OGG and WAV
reading, so I don’t have to learn how a bunch of utility libraries
work?

You can have a look at FMOD library, it’s not LGPL but it is cross
platform and has all the features you requested, I’v been using it
myself instead of SDL_Mixer because of strange gaps and glitches when
playing MP3 files at 44100KHz and very hard CPU usage for mixing, it
isn’t optimized…hope someone one day will optimize it :slight_smile:

FMOD isn’t GPL-compatible, so it can’t be used with GPL-licensed
projects any more than Bass can.


Glenn Maynard


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

StepMania is GPL, not LGPL.On Fri, Nov 08, 2002 at 02:43:59PM -0600, Robert Diel wrote:

I thought with LGPL products all you needed to do was:

"1. Include the source code for the version of SDL that you link
with, as well as the full source or object code to your application so
that the user can relink your application, "


Glenn Maynard

has anyone had problems with the SDL_Mixer in windows…?

because i ask questions about this and NO ONE ever answer.
or maybe i am the only one who has trouble with it.

please if anyone had a problem can tell me what have you done to solve it.

my problem is that the sound is not going out the speakers. the program compiles allright and the program run all the time the sound last. but (i repeat) no sound is coming out,

thanks for answer this.

Hmmm.

Have you checked that SDL initialised the audio correctly, and that you’ve set the volue sample size, and so on?----- Original Message -----
From: David
To: sdl at libsdl.org
Sent: Tuesday, January 07, 2003 2:12 PM
Subject: [SDL] SDL_Mixer

has anyone had problems with the SDL_Mixer in windows…?

because i ask questions about this and NO ONE ever answer.
or maybe i am the only one who has trouble with it.

please if anyone had a problem can tell me what have you done to solve it.

my problem is that the sound is not going out the speakers. the program compiles allright and the program run all the time the sound last. but (i repeat) no sound is coming out,

thanks for answer this.

Hmmm.

Have you checked that SDL initialised the audio correctly, and that you’ve set the volue sample size, and so on?

yes i’ve check it… here’s the code… could it be some problem with the driver?

int main(int argc, char *argv[])
{
Mix_Chunk *sonido;

if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
printf (“Error: %s\n”, SDL_GetError());
return 1;
}

if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 2048) < 0) {
printf (“Error: %s\n”, Mix_GetError());
return 1;
}

atexit(SDL_Quit);
atexit(Mix_CloseAudio);
Mix_Volume(0,255);

sonido = Mix_LoadWAV(“Galaga.wav”);
if (!sonido) {
printf (“Error: %s\n”, Mix_GetError());
return 1;
}

Mix_AllocateChannels(8);
if (Mix_PlayChannel(-1, sonido, 0) < 0) {
printf (“Error: %s\n”, Mix_GetError());
return 1;
}

while(Mix_Playing(-1)!= 0) ;

Mix_FreeChunk(sonido);
return 0;
}----- Original Message -----
From: Rob
To: sdl at libsdl.org
Sent: Tuesday, January 07, 2003 12:44 AM
Subject: Re: [SDL] SDL_Mixer

my problem is that the sound is not going out the speakers. the
program compiles allright and the program run all the time the sound
last. but (i repeat) no sound is coming out,

Are you getting calls to your defined callback when you open the device?
Are you getting an error code back from SDL_OpenAudio? You need to open a
stream and do the work before SDL_Mixer will work.

Example below for opening an audio stream:

sDesired.freq = dwSamplingRate;
sDesired.samples = AUDIO_BUFFER_SIZE;
sDesired.callback = SDLAudioCallback;

s32SDLResult = SDL_OpenAudio(&sDesired,
							 NULL);

if (s32SDLResult < 0)
{
	// Couldn't open things up

	return(FALSE);
}

–>Neil-------------------------------------------------------------------------------
Neil Bradley In the land of the blind, the one eyed man is not
Synthcom Systems, Inc. king - he’s a prisoner.
ICQ #29402898