summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/midiplay.c
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-10-08 19:28:41 +0000
committerNils Wallménius <nils@rockbox.org>2007-10-08 19:28:41 +0000
commitf619f8167646632d6eab10f529638eebbdda6af6 (patch)
tree119a1f4051d59808a25612421f613cb09ee1e9d5 /apps/plugins/midi/midiplay.c
parentd712e252fecf814a48814034a55ba60a1b194598 (diff)
Change loop structure for sample synthesizing. Gives a nice speedup on both coldfire and arm targets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15036 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi/midiplay.c')
-rw-r--r--apps/plugins/midi/midiplay.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index c557433dce..99f05718d6 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -148,32 +148,31 @@ bool lastswap=1;
static inline void synthbuf(void)
{
- int32_t *outptr;
- register int i;
- int currentSample=0;
- int synthtemp[2];
+ int32_t *outptr;
+ int i;
#ifndef SYNC
- if(lastswap==swap) return;
- lastswap=swap;
+ if(lastswap==swap) return;
+ lastswap=swap;
- outptr=(swap ? gmbuf : gmbuf+BUF_SIZE);
+ outptr=(swap ? gmbuf : gmbuf+BUF_SIZE);
#else
- outptr=gmbuf;
+ outptr=gmbuf;
#endif
- for(i=0; i<BUF_SIZE; i++)
- {
- synthSample(&synthtemp[0], &synthtemp[1]);
- currentSample++;
- *outptr=((synthtemp[0]&0xFFFF) << 16) | (synthtemp[1]&0xFFFF);
- outptr++;
- if(currentSample==numberOfSamples)
- {
- if( tick() == 0 ) quit=1;
- currentSample=0;
- }
- }
+ for(i=0; i<BUF_SIZE/numberOfSamples; i++)
+ {
+ synthSamples((int32_t*)outptr, numberOfSamples);
+ outptr += numberOfSamples;
+ if( tick() == 0 )
+ quit=1;
+ }
+
+ if(BUF_SIZE%numberOfSamples)
+ {
+ synthSamples((int32_t*)outptr, BUF_SIZE%numberOfSamples);
+ outptr += BUF_SIZE%numberOfSamples;
+ }
}
void get_more(unsigned char** start, size_t* size)