summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-09-30 19:22:57 +0000
committerNils Wallménius <nils@rockbox.org>2007-09-30 19:22:57 +0000
commitf9664e7e87a17c675f8a0da78466d47ff5f4875f (patch)
tree09021aa75271008393d6339ca45cc051a4dfe1c4 /apps/plugins
parent035529c487feb5a0e1d951b1ac8f82c23cfbff62 (diff)
Unroll a frequently executed loop a little for a small speedup
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14924 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/midi/synth.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/apps/plugins/midi/synth.h b/apps/plugins/midi/synth.h
index 5edaf2b7bf..223b5974e2 100644
--- a/apps/plugins/midi/synth.h
+++ b/apps/plugins/midi/synth.h
@@ -16,20 +16,37 @@
* KIND, either express or implied.
*
****************************************************************************/
-
int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig);
signed short int synthVoice(struct SynthObject * so);
void setPoint(struct SynthObject * so, int pt);
static inline void synthSample(int * mixL, int * mixR)
{
- register int dL=0;
- register int dR=0;
- register short sample=0;
- register struct SynthObject *voicept=voices;
- struct SynthObject *lastvoice=&voices[MAX_VOICES];
+ int i;
+ register int dL=0;
+ register int dR=0;
+ register short sample = 0;
+ register struct SynthObject *voicept=voices;
+
+ for(i=MAX_VOICES/2; i > 0; i--)
+ {
+ if(voicept->isUsed==1)
+ {
+ sample = synthVoice(voicept);
+ dL += (sample*chPanLeft[voicept->ch])>>7;
+ dR += (sample*chPanRight[voicept->ch])>>7;
+ }
+ voicept++;
+ if(voicept->isUsed==1)
+ {
+ sample = synthVoice(voicept);
+ dL += (sample*chPanLeft[voicept->ch])>>7;
+ dR += (sample*chPanRight[voicept->ch])>>7;
+ }
+ voicept++;
+ }
- while(voicept!=lastvoice)
+ for(i=MAX_VOICES%2; i > 0; i--)
{
if(voicept->isUsed==1)
{