error in play_sample()
aadfo824

Hello. I am writing a platform scrolling version of Shakespeare's Romeo and Juliet. I built it and it worked perfectly; until I added another level. It "asked Runtime to terminate it in an unusual way" every time I tried to play a sound effect. Mind you, I didn't touch the sound effect code. Strangely, the background music still works perfectly.

I know that the samples are being loded perfectly, and the VC debugger says that play_sample() is causing the problem. Any ideas?

I have already severly flogged myself for not backing up the code.

ImLeftFooted

Run a backtrace and paste the results here.

aadfo824

How do I run a backtrace?

ImLeftFooted

For Visual Studio? I don't know, probably the little box on the bottom or something.

For gcc, you add -ggdb3 -g3 to your compile and linker commands. Then you run gdb yourprogram.exe which gives you a command prompt where you can type run<enter>. Once it crashes you type backtrace<enter>.

aadfo824

(prepares wakizashi for Seppuku)

I looked at the line in sound.c where the error occured and found out that play_sample() has a volume range of 0-255. It turns out that I was playing my sounds at volume 256, but the music at 32 (the music is much louder than the sound effects). That it is why the music worked but the effects caused an error; however, I'm still in the dark about why the too loud sounds worked earlier. Oh well.

/* Thanks anyway! */

Damn your good!

[Edited while you were posting]

ImLeftFooted

No thats just the verbose output. The juicy line is this one:

Assert failed at line 1194 of src/sound.c

You're going to want to set a breakpoint at src/sound.c on line 1194. When the breakpoint is reached you'll want to find the backtrace window on the bottom somewhere.

Also, what is the exact version of allegro you are using?

**

Allegro 4.2 Branch said:

 1193    ASSERT(spl);
 1194    ASSERT(vol >= 0 && vol <= 255);
 1195    ASSERT(pan >= 0 && vol <= 255);
 1196    ASSERT(freq > 0);

Alright, So I'm going to guess that either:

  1. You're passing in null to play_sample

  2. You're passing in a negative value or a value equal to or greater then 255 for the volume.

  3. You're passing in a negative value or a value equal to or greater then 255 for the pan.

  4. You're passing in something 0 or less then 0 for the frequency

With my highest bet on problem number 2.

Thread #591172. Printed from Allegro.cc