Thanks Sam! Next question: -> Audio rate 44100 not supported!

Thanks Sam for that great link.

Sorry to bother you people again, but I simply must ask for help.
I am a newbie to SDL. I am porting a program originally written
using DirectX in VC to SDL. There was no problem until I used
SDL_mixer instead of FMOD which was used in original code.

My problem is in this code…

Uint16 audio_rate = MIX_DEFAULT_FREQUENCY;
Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */
Uint16 audio_channels = 2;       /* Stereo */
Uint16 audio_buffers = 4096;

if (Mix_OpenAudio (audio_rate, audio_format, audio_channels, 

audio_buffers))
{
fprintf (stderr, “Mix_OpenAudio: Unable to open audio!\n”);
return false;
}

The problem arises when I use
Uint16 audio_rate = 44100;

instead of
Uint16 audio_rate = MIX_DEFAULT_FREQUENCY; // = 22050

The sound quality increases and thats good. But while terminating,
the program crashes.

The error report says…
AppName: Space war.exe AppVer: 0.0.0.0 ModName: ntdll.dll
ModVer: 5.1.2600.0 Offset: 000054d8

Exception Information
Code: 0xc0000000000000000 Flags: 0x00…
Record: 0x00… Address: …

System Information
Windows NT 5.1 Build: 2600
CPU Version: 00000653 CPU Feature Code: 0183F9FF

and blah… blah…

I know this is not enough to guess what heppened but I have a hint
that NTDLL.DLL crashed whenever I tried to use 44100 audio rate in
MixOpenAudio function.

The system is:--------------
CPU: PII - 400MHz (Obviously 32bit :wink:
Graphic Card: Intel i740
Graphic Card driver: Manufacturer:- Microsoft
Driver version:- 5.1.2001.0
RAM: 256 MB SDRAM
Sound Card: Crystal CS4236B
Driver Manufacturer:- Microsoft
Driver Version:- 5.1.2535.0
OS: WinXP Pro (ver 2002)

Please, please, please… somebody help me! Its an emergency! :wink:

I need to learn more and more and more and more … I want
the finest detail about how this library works (because its a GREAT
lib and I am fascinated by its power and simplicity and … of
course, games! Heh heh!)

Also, I would like to repeat my previous question again…
How can I use 32 bit quality sound with SDL?

FMOD uses it like this…
FSOUND_Init(48000, 32, FSOUND_INIT_USEDEFAULTMIDISYNTH);

Sam, please help me! Because I want to see this lib on the top!!

Thanks.
Nayan

Sorry to bother you people again, but I simply must ask for help.
I am a newbie to SDL. I am porting a program originally written
using DirectX in VC to SDL. There was no problem until I used
SDL_mixer instead of FMOD which was used in original code.

My problem is in this code…

Uint16 audio_rate = MIX_DEFAULT_FREQUENCY;
Uint16 audio_format = AUDIO_S16; /* 16-bit stereo /
Uint16 audio_channels = 2; /
Stereo */
Uint16 audio_buffers = 4096;

if (Mix_OpenAudio (audio_rate, audio_format, audio_channels,
audio_buffers))
{
fprintf (stderr, “Mix_OpenAudio: Unable to open audio!\n”);
return false;
}

The problem arises when I use
Uint16 audio_rate = 44100;

instead of
Uint16 audio_rate = MIX_DEFAULT_FREQUENCY; // = 22050

The sound quality increases and thats good. But while terminating,
the program crashes.

It sounds like you might have a memory overwrite problem in your sound
mixing code. It’s fairly common, you might try using a bounds checking
memory debugging tool to help find the problem.

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

Also, I would like to repeat my previous question again…
How can I use 32 bit quality sound with SDL?

SDL doesn’t support 32-bit sound. What FMod is using is a 32-bit internal
mixing buffer, and then usually converting it to 16-bit sound for the final
output. This results in high mixing quality, and you can do the same thing
when mixing SDL audio, like this:

int sample = 0;
for ( i = 0; i < numchannels; ++i ) {
	sample += channel[i].data[channel[i].pos++];
}
if ( sample > 32768 )
	output = 32768;
else if ( sample < -32767 )
	output = -32767;
else
	output = (Sint16)sample;

This is rough, but you see the idea…

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