#164121 - Ruben - Tue Oct 21, 2008 7:26 am
Hey all.
OK, I don't know whether this should go under the audio section or here, but since it's more logical than anything else...
The basic idea of my "main" (mixing) algorithm is to multiply by the volumes like so..
value = (volume left OR (volume right LSL 16)) * sample
value &= ~((maximum channels-1) LSL 16) //32 channels max
value = value LSR (channel count bits) //5 bits for 32
Or more graphically...
That's all OK and everything, but then comes a problem at the "final" (mix down) step.
Since I'm using a "fixed point multiplier" (the global volume) at the end to scale the values, anything that's >= 80h has no distortion, but anything BELOW that... ayayay! And also, I've got a problem for clamping (clipping), as I can't think of any conventional method to clip that. (Maximum value: 7Fh, minimum value: -80h)
EDIT:
Whoops. Wrong section. Can someone move it to coding or the appropriate one? Thanks.
OK, I don't know whether this should go under the audio section or here, but since it's more logical than anything else...
The basic idea of my "main" (mixing) algorithm is to multiply by the volumes like so..
value = (volume left OR (volume right LSL 16)) * sample
value &= ~((maximum channels-1) LSL 16) //32 channels max
value = value LSR (channel count bits) //5 bits for 32
Or more graphically...
Code: |
FFFFFFBC <- -44
MUL 007F 007F <- Volume ------------- DE43 DE44 BIC 001F 0000 <- (32-1)<<16 ------------- DE40 DE44 LSR 5 ------------- 06F2 06F2 |
That's all OK and everything, but then comes a problem at the "final" (mix down) step.
Since I'm using a "fixed point multiplier" (the global volume) at the end to scale the values, anything that's >= 80h has no distortion, but anything BELOW that... ayayay! And also, I've got a problem for clamping (clipping), as I can't think of any conventional method to clip that. (Maximum value: 7Fh, minimum value: -80h)
EDIT:
Whoops. Wrong section. Can someone move it to coding or the appropriate one? Thanks.