#4616 - SmileyDude - Fri Apr 04, 2003 11:19 pm
Hi everyone,
I'm currently trying to implement an efficient mixer. My goal is to be able to play standard 4-track .mod files (2 left, 2 right), along with an additional 2 channels capable of panning left and right for sound effects. The music channels will be playing samples at varying rates, while the sound effects channels will be playing samples at the same rate as the sound hardware is playing at.
I've been reading some of the other posts on here, and I've seen references to being able to mix 3 and sometimes even 4 channels at one pass, but I can't figure out a way to mix more than 2 without re-loading registers during the mix loop. Note, this is of course assuming that the samples being played back are at various rates. If the sample rates are the same as the mix rate, then it's relatively easy to mix multiple channels at once.
Another alternative is to loop through each channel, and mix them into the buffer -- but, as far as I can tell, this requires twice as many load/stores as opposed to doing it in one pass. I do realise that I will need to break up into multiple passes for the sound effects, but that shouldn't be too much of a problem.
So, what I have so far is a single optimised case for two samples playing on a channel at once, and both samples loop. I only have 2 (3 if i use the SP) extra registers remaining after this -- here's what I have allocated:
r0 - sample1 ptr
r1 - sample1 offset (16.16)
r2 - sample1 increment (16.16)
r3 - sample1 volume
r4 - sample1 loop len (16.16)
r8 - r12 - same as r0-r4, but for sample2
r5 - output value
r6 - output ptr
r7 - tmp
r13 - sp
r14 - tmp
r15 - pc
I can't think of anyway of squeezing out another register or 2 to get a third sample in the loop -- but, it seems like it should be able to be done based on the other posts in this forum.
I still have to work out special case code for non-looping samples, no sample playing, 1 sample playing, etc, etc. But that shouldn't be too big of a deal.
Does anyone have any suggestions? I plan on releasing whatever comes of this as an aid to anyone else working on adding sound support to their project. Hopefully, we'll be able to come up with a really good mixer that could be used for projects that don't require a lot of complexity :)
_________________
dennis
I'm currently trying to implement an efficient mixer. My goal is to be able to play standard 4-track .mod files (2 left, 2 right), along with an additional 2 channels capable of panning left and right for sound effects. The music channels will be playing samples at varying rates, while the sound effects channels will be playing samples at the same rate as the sound hardware is playing at.
I've been reading some of the other posts on here, and I've seen references to being able to mix 3 and sometimes even 4 channels at one pass, but I can't figure out a way to mix more than 2 without re-loading registers during the mix loop. Note, this is of course assuming that the samples being played back are at various rates. If the sample rates are the same as the mix rate, then it's relatively easy to mix multiple channels at once.
Another alternative is to loop through each channel, and mix them into the buffer -- but, as far as I can tell, this requires twice as many load/stores as opposed to doing it in one pass. I do realise that I will need to break up into multiple passes for the sound effects, but that shouldn't be too much of a problem.
So, what I have so far is a single optimised case for two samples playing on a channel at once, and both samples loop. I only have 2 (3 if i use the SP) extra registers remaining after this -- here's what I have allocated:
r0 - sample1 ptr
r1 - sample1 offset (16.16)
r2 - sample1 increment (16.16)
r3 - sample1 volume
r4 - sample1 loop len (16.16)
r8 - r12 - same as r0-r4, but for sample2
r5 - output value
r6 - output ptr
r7 - tmp
r13 - sp
r14 - tmp
r15 - pc
I can't think of anyway of squeezing out another register or 2 to get a third sample in the loop -- but, it seems like it should be able to be done based on the other posts in this forum.
I still have to work out special case code for non-looping samples, no sample playing, 1 sample playing, etc, etc. But that shouldn't be too big of a deal.
Does anyone have any suggestions? I plan on releasing whatever comes of this as an aid to anyone else working on adding sound support to their project. Hopefully, we'll be able to come up with a really good mixer that could be used for projects that don't require a lot of complexity :)
_________________
dennis