tokumaru wrote:
As for a global volume setting (i.e. fading songs/effects), couldn't you use a 256-byte look-up table to "mix" each channel's volume with a global volume to get the final volume setting? Like, have the global volume in the upper 4 bits, OR it with the channel's volume which are in the lower 4-bits, and use the result as an index to look up the final volume in the 256-byte look-up table.
I thought that I would simply have a regular byte variable. And when I want to fade-out the music, I would decrement the volume in each channel by the current value of the variable.
I.e., usually my variable is 0, so the volumes are the original ones:
NewVolume = OldVolume - 0
But when I want to fade out, I increment the value every few frames, until it has reached 15.
This means the volume values will be reduced every few frames and eventually, all of them will be at 0:
NewVolume = OldVolume - 1
NewVolume = OldVolume - 2
NewVolume = OldVolume - 3
...
NewVolume = OldVolume - 15
(Of course, paying attention that a value that's already at 0 doesn't get decremented any further since this would just set it back to maximum again.)