Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » bad sound quality when playing certain samples

This thread is locked; no one can reply to it. rss feed Print
bad sound quality when playing certain samples
Gerwin Broers
Member #3,681
July 2003
avatar

Yesterday I noticed that one of the background sounds in my game (looped) sounds very poor. Though, When playing that wav file with another windows based media player program, it sounds better?
I tried doing a very basic approach in loading and playing the sound (as below), but it remains poor. Or is my hearing fooling me.. I attached the specific wav file in which I noticed the difference. it is 8 bit, mono, sample rate 22000.

Why is this quality drop, how can I improve the sound quality?

----------------------------------------------
SAMPLE *song; // create a SAMPLE pointer
song = load_sample("amb03.wav"); // loads the entire wav file into memory
play_sample(song, 255, 127, 1000, false); // play the sound
// first parameter, the SAMPLE
// second, the volume (0-255)
// third, pan (0 left, 255 right)
// forth, sample rate (1000 - normal), 500 half, 2000 double...
// last parameter is looping

Main Project: HeroQuest. And Other Stuff

Kris Asick
Member #1,424
July 2001

Sounds fine on my system, both using Allegro and straight through Media Player.

Is it just that sound effect that's giving you trouble, or are others doing it too? There could be a variety of reasons why it's not sounding correct in your code.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Paul whoknows
Member #5,081
September 2004
avatar

Quote:

Yesterday I noticed that one of the background sounds in my game (looped) sounds very poor. Though, When playing that wav file with another windows based media player program, it sounds better?

Same thing happened to me once, nobody could explain this, and still it doesn't work properly, not only the sound quality is affected, also during playback the sound is speed it up.
I think this is an Allegro bug, however you can disable DIGI_AUTODETECT and try the different configuration for digital drivers and see which one works for you, obviously the problem is still there :-/

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Gerwin Broers
Member #3,681
July 2003
avatar

So one reply "nothing wrong here" and one "got that too"...
the score is 1-1. I will be trying some stuff.

It is a bit hard to determine sound quality, this one sample is obvious though, in the game it sounds like a defective speaker squeaking.
I have got a soundblaster Live, I am running Win98Se.

Now I have just tried running it on my windows 2000 PC, with the same soundcard, guess what: it sounds better!

Main Project: HeroQuest. And Other Stuff

Kitty Cat
Member #2,815
October 2002
avatar

What version of Allegro? Do you change any of the mixer settings? What are the playback settings on the Win98 system (check get_mixer_bits, get_mixer_frequency, and get_mixer_channels; get_mixer_quality would be nice, too)?

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

miran
Member #2,407
June 2002

Quote:

it is 8 bit, mono, sample rate 22000

Do you still have that sample at the original full quality? If so, try exporting it to 8bit, mono, sample rate 22050. Perhaps on the Win98SE machine some mixer at some point in the process doesn't cope quite that well with resampling 22000 Hz to 22050 or 44100 and introduces a lot of aliasing. Or something...

--
sig used to be here

Kris Asick
Member #1,424
July 2001

My guess is something's up with the computer it's not sounding fine on. Such as too many applications running in the background, outdated drivers for your sound or video card, or something like that. You may also have the internal volume settings too high and it's thus distorting the sound effect. Try turning the Windows volume slider down and your own speakers up and see if that helps. If it does, it's a volume thing. If not, then it's a software or driver thing.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Audric
Member #907
January 2001

I had some Win98 sound problems as well, some years ago: it sounds like a 16bit sample fed "as is" to a 8bit voice, or the other way round.
I got it only with the DOS/DJGPP port of Allegro, when running the executable in Windows 98 (I couldn't test the exe on vanilla DOS mode, no DOS drivers for my soundcard)
IIRC, it started happening on one of the last 3.9 Allegro WIPs.
I got it when compiling Dosdoom and Boom: for some months it was alright, after some Allegro update the sound was screwed.

Might be worth investigating the allegro.cfg as well : maybe a new allegro.cfg is mis-read by an old allegro executable, or the other way round.

edit: By the way: I also have a SB Live.

Kris Asick
Member #1,424
July 2001

Just for the record, I have an SB Live card too, am using Allegro 4.2.0, and work in Windows 98SE, and have never encountered the problems being described... Just in case someone wanted to blame that specific combination. I'm certain there's more to it.

Other things you might want to try, Gerwin, is trying different video modes, both full-screen and windowed, testing the sound effect in the Grabber application, essentially, expose the sound through Allegro to as many different environments and configurations as you can on your one system.

See if you can't narrow down what combination of things is making the sound effect go screwy in Allegro.

You may also want to try going into your multimedia settings through the control panel and checking out the advanced properties for your sound settings. See if altering any of the acceleration sliders helps.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Gerwin Broers
Member #3,681
July 2003
avatar

Ok, first of all, thanks you for the replies!

I requested mixer's bits, frequency, channels, quality, voices. which gave 16,44100,2,2(=interpolated 16-bit mixing),8. Sound driver used is directsound. Using DIGI_WAVOUTID(0) the program locks up.

I played the wav file from within the grabber on the same system, it sounds good!

I played the wav file from this minimalistic program, it sounds bad:

#include "allegro.h"
int main(int argc, char *argv[])
{
allegro_init();
install_keyboard();
install_mouse();
install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
SAMPLE *song; // create a SAMPLE pointer
song = load_sample("amb03.wav"); // loads the entire wav file into memory
play_sample(song, 255, 127, 1000, false); // play the sound
readkey();
allegro_exit();
return 1;
}
END_OF_MAIN();

Now I don't see anything fancy grabber.c, what is the difference between the grabber and the program above in playing the sample?

Main Project: HeroQuest. And Other Stuff

Richard Phipps
Member #1,632
November 2001
avatar

Kris Asick
Member #1,424
July 2001

The Grabber is initializing a graphics mode. You aren't.

Try setting yourself into a graphics mode before playing the sound effect and see if that helps.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Paul whoknows
Member #5,081
September 2004
avatar

Like I said, I have the same problem, (Windows XP, Audio Aureal Vortex 8830(WDM)).
This only happens with programs using allegro, when I play the same samples with other players like winamp or WMP everything sounds fine.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Gerwin Broers
Member #3,681
July 2003
avatar

- The grabber played the sample fine, because it was still compiled for version 4.0.3 of allegro, using alleg40.dll. When trying a later grabber.exe, using alleg42.dll the playback sucks again, just like my game and test program (which also use alleg42.dll).

So the problem, as I have it, was introduced with version 4.2.0. Which figures because otherwise I would have noticed the the problem earlier.

- reserve voices makes no difference .

- initializing graphics mode first makes no difference.

- the sample rate of the file was indeed 22050 instead of 22000, that was a typo.

Main Project: HeroQuest. And Other Stuff

Kitty Cat
Member #2,815
October 2002
avatar

Can you print out the digi_driver->name and digi_driver->desc strings (of both the 4.0.3 and 4.2.0 programs)? Actually the play command in the test/ directory should do that.

What do you mean by 'poor', anyway? Does it have static, is it quieted, is it muffled, does it have a 'whine', or..?

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Gerwin Broers
Member #3,681
July 2003
avatar

Well then,

Attached the distorted wav, in my first post of this topic you can find the original one.

digi_driver->name and digi_driver->desc strings
both say "allegmix directsound (sb live [E800])" or similar in both cases.

next I discovered my sound hardware acceleration setting was in setting 2 of 4. which is necessary for running Jane's usaf flightsim properly. Setting acceleration to 4/4 makes the problem go away..... damn, so it is very specific, probably too specific to invest any time in, but I did not know that when starting this topic.

Main Project: HeroQuest. And Other Stuff

Go to: