[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Whilst I am all for an increase in precision, I don't think the existing
problems are half as bad as you imply they are:
On Tuesday 16 March 2004 16:13, Chris wrote:
> After migrating from Windows to Linux, and thus away from Allegro's DX
> mixer, I was horrified to learn that the volume problems are still
> there. This is amplified by the fact that the DIGMID driver chews up so
> many voices, everything becomes quite inaudible, even when playing
> note-heavy MIDIs.
That's what set_volume_per_voice() is for, surely. It's a shame people using
the DirectX mixer on Windows wouldn't know they need to use it though.
> So, what I did was play around with Allegro's software
> mixer, and ended up accomplishing these things (these only apply to the
> high quality mixers; the low quality one "quality = 0" remains mostly
> unchanged):
> * The volume no longer decreases as more voices are allocated
This is only default behaviour anyway.
> * Samples now clamp to 0 and 65535 without using branching or assuming
> signed right-shifts; as a result, the output no longer wraps and causes
> distortion
The output never did wrap and cause distortion, unless you went to something
like 4x the volume at which it would be clamped. If you're doing this, then
your distortion is pretty bad anyway and you should reduce the overall
volume_per_voice.
Just one thing though: is the clamping done after each sample is mixed, or is
it done at the end? The former may cause unnecessary distortion, and may be
slower (though the latter does require either a data type with a larger
range, e.g. 32-bit ints, or a loss of precision, as with the old 14-bit
mixing).
> * The internal volume range now uses full 16 bit precision, instead of 14
> * The maximum output volume is now full 16 bit as well, instead of 13(!)
These are good :)
> * The clipping table used by the mixer was removed (unneeded due to
> clamping)
> * High quality mixers can be selected even if 8 bit audio output is used
> (the 16->8 conversion is done after mixing, so I don't see why the mixer
> selection should be affected by this)
That will make the 8-bit mixer more expensive to run - so before we do it,
we'd better check that no one has a 386 or possibly a 486 any more :P
> I realize that removing the set_volume_per_voice functionality for the
> non-low quality mixers was probably a bad idea.
Yes, it was. The parameter to the function is game-specific, and my games use
the function. So do put it back in.
> It should be simple
> enough to add that back in, letting set_volume_per_voice(0) play
> everything at full volume, but this way it gives full volume control via
> set_volume. I would also recommend that if set_volume_per_voice should
> be restored (which I can do simply enough), that set_volume_per_voice(0)
> be the default for the high quality mixers.
Unfortunately, this means that just two samples playing at once with volume
255 - or one with volume 255 and panning off centre - will distort. Not a
good idea.
I did want a change ages ago, but people argued with me on the grounds that we
shouldn't change the default. So I added set_volume_per_voice() while making
sure the default behaviour would always be the same as before.
However, there is currently a huge rift between the behaviour of the
DirectSound mixer and the Allegro mixer. Developers, please reconsider your
position: should Allegro's mixer default to simulating the old Allegro mixer,
or should it default to being as close as possible to the DirectSound mixer?
Or should the DirectSound mixer try to simulate Allegro's?
> PS. According to the GCC manual, the compiler won't inline with -O2. You
> need to either specifiy -finline-functions or -O3. So those inline
> functions in the source aren't being inlined, nor locked. Isn't this a
> timer hazard?
Yep, it would be. I'm wondering if the functions would have been #defines once
in the past. Check that there isn't an END_OF_FUNCTION([first function's
name]) right at the end after all the functions; I've seen that before in
Allegro's source. (Me too lazy to actually LOOK at the source :)
Ben