Re: [AD] Sound API

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


On Mon, 2004-05-17 at 02:08, Chris wrote:
> Ben Davis wrote:
> > Just out of interest, what volume bug are we talking about here? I was using 
> > set_volume_per_voice(0), so it should have played at full volume already; it 
> > did for me.
> 
> Allegro will never play at full volume without my patch. Remember, the 
> clipping table will clip it to a max of 14-bit output (lest output 
> wraps), and also the internal volume ranges were only 13 or 14-bit too. 
> My patch allows the volume range to be a full 16-bit, and mixes in full 
> 24-bit precision until it's scaled down to whatever the driver wants. It 
> even interpolates 8-bit samples with full 24-bit precision, instead of 
> interpolating fully in 8-bit then scaling up like it does now.
> 

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.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





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