Re: [AD] Sound API

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Elias Pschernig wrote:
I think I can resolve this all with a picture:

http://allefant.sf.net/uploads/set_volume_per_voice.png

What happens is, I create this 16-bit stereo sample:

SAMPLE *sine = create_sample (16, 1, 44100, 44100);
int i;
float f = 420;
uint16_t *data = sine->data;
for (i = 0; i < 44100; i++)
{	
	data[i * 2] = 32768 + 32767 * sin ( 2 * AL_PI * f * i / 44100.0);	
	data[i * 2 + 1] = 32768 + 32767 * sin ( 2 * AL_PI * f * i / 44100.0);
}

Then play it:

play_sample (sine, 255, 128, 1000, 0)

This is done 3 times, with set_volume_per_voice 0, 1 and without it at
all.

The first 3 are with the new mixer, respectively, the last 3 (as is
obvious from the picture) with the old mixer.

You should add both channels together when showing output volume, and you'll see that set_volume_per_voice(0) easilly overflows. Currently with my mixer, you can't get any louder than set_volume_per_voice(1), which is the "default" volume for a voice (the max without risking any overflow). I can reimplement set_volume_per_voice(0), but for your typical game I personally don't believe there's any need for, or that it's even worth, it.

- Kitty Cat




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/