[AD] Voice per volume - a few questions

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


I've programmed voice-per-volume functionality into mixer.c. That means the
user can set a global variable, int voice_volume_scale, to control the
volume of each soundcard voice. This variable is -1 by default, telling
Allegro to calculate a value to simulate its old behaviour (well, almost).
The variable's value is used once in _mixer_init() to create the volume
table(s), so changing it later makes no difference.

NOTE: The mixer code now *always* uses the clipping table. Before, it only
used it for 8 voices or more. The problem was, in addition to clipping, the
table had the effect of amplifying by a factor of 4. If the clipping table
was disabled, everything would be quieter.

If the variable is -1 at the time when sound is installed, it will be
possible to play up to n_voices/2 centred samples at maximum volume without
risking distortion, or n_voices/4 on one panning extreme. For mono drivers,
it will be possible to play up to n_voices/2 samples without risking
distortion. (n_voices is the number of voices reserved, obviously.)

The exception is if there are fewer than 8 voices. Then volume per voices
will be the same as if 8 voices were reserved. This can be overridden by
setting voice_volume_scale to something else.

If the variable is set to 0, each voice will play at half maximum volume in
both channels or mono drivers, or full maximum in only one channel, or
something in between (depending on the pan). Each time the variable is
increased by 1, the volume halves.

The clipping table can accommodate samples up to 4 times the maximum output.
If the resulting volume per voice is too high to stay within this limit, it
will be reduced. You cannot reserve 64 voices and have each one play at
maximum volume!

Now for the questions...

1. Is it true that *all* digital sound drivers do, and always will, use the
Allegro mixer? (I think this would be a good idea, so that all versions work
similarly.)

2. I have set up the variable in the source file mixer.c, and am ready to
create a reference to it in allegro.h. Is this acceptable, or would anyone
rather I move the variable to sound.c, or create a function for changing it,
or something?

3. I am perfectly willing to write documentation for the new
variable/function. I can modify allegro.txt - does anything else need
modifying, and if so, how?

4. I've written the following at the top of the source file. "Ben Davis
provided the voice_volume_scale functionality, programmed the silent mixer
so that silent voices do not freeze, and fixed a few minor bugs elsewhere."
However, this seems much longer than most of the other credits. Can someone
advise me, so I don't sound too self-important please? :-)

5. Can anyone think of any other questions I should be asking?

Thanks for your patience,

Ben Davis



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