#162408 - Ruben - Tue Sep 02, 2008 11:50 am
I was wondering how I'd be able to mix more than 2 channels at once when the volume is 127+. I know the GBA's BIOS synth can mix up to 12 channels, and it uses signed data. Since I've done a lot of experiments, it seems that the only way would be to use a halfword load (my temp. buffer uses halfwords), multiply by left, shift, store halfword, load halfword, multiply by right, shift, store halfword.
That's good and all but... isn't there a faster method of doing this? Doesn't AAS use signed samples as well? Cos from the speed it has, it can't make 3+ loads, multiplication and 2 stores per sample and keep ~1.0% CPU per channel.
EDIT:
After lots of days of thinking and through trial and error, I finally found the way to do this right.
That's good and all but... isn't there a faster method of doing this? Doesn't AAS use signed samples as well? Cos from the speed it has, it can't make 3+ loads, multiplication and 2 stores per sample and keep ~1.0% CPU per channel.
EDIT:
After lots of days of thinking and through trial and error, I finally found the way to do this right.
Code: |
@ assume that...
@ r0: *dst @ r1: *wav @ r2: vol left OR (volume right SHL 16) (in this case 007F007Fh) ldr r3, [r0] @ 0x00000000 ldrsb r4, [r1], #1 @ 0xFFFFFFFB mul r4, r2, r4 @ 0xFD84FD85 (1 sample error; gets shifted) bic r4, r4, #0x70000 @ 0xFD80FD85 add r3, r3, r4, lsr #3 @ 0x1FB01FB0 (yes, LSR, not ASR) str r3, [r0], #0x04 ... then when mixing down... ... @ assume that... @ r0: *src @ r1: *dst ldrh r2, [r0] @ 0x1FB01 (yes, LDRH, not LDRSH) mov r2, r2, asr #5 cmp r2, r2, #0xFF movgt r2, r2, #0xFF strb r2, [r1], #1 |