diff options
author | Nils Wallménius <nils@rockbox.org> | 2007-09-27 18:29:50 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2007-09-27 18:29:50 +0000 |
commit | 93787dd42c57d8af8127b26a9c46f0a4e3e80d0e (patch) | |
tree | 80cd6dff15ac136096722810ac3c6b5dd2910151 /apps/plugins/midi | |
parent | 5ec5f8abacf56b082480f8a33fa937c16d496011 (diff) |
Simplify the sendEvent function, makes it _slightly_ faster and quite a bit smaller, build midiplay with -O2 for coldfire, gives about a 23% speedup
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14872 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi')
-rw-r--r-- | apps/plugins/midi/Makefile | 9 | ||||
-rw-r--r-- | apps/plugins/midi/midiutil.h | 1 | ||||
-rw-r--r-- | apps/plugins/midi/sequencer.c | 77 |
3 files changed, 48 insertions, 39 deletions
diff --git a/apps/plugins/midi/Makefile b/apps/plugins/midi/Makefile index 0d81c87b4b..94359024f1 100644 --- a/apps/plugins/midi/Makefile +++ b/apps/plugins/midi/Makefile @@ -9,7 +9,14 @@ INCLUDES = -I$(APPSDIR) -I.. -I. $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export \ -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) -CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(EXTRA_DEFINES) \ + +ifeq ($(CPU),coldfire) + MIDIOPTS = -O2 +else + MIDIOPTS = -O +endif + +CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(EXTRA_DEFINES) $(MIDIOPTS) \ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN ifdef APPEXTRA diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h index cfaa4fb2fe..26e46b98b8 100644 --- a/apps/plugins/midi/midiutil.h +++ b/apps/plugins/midi/midiutil.h @@ -140,7 +140,6 @@ struct Track int printf(const char *fmt, ...); int midimain(void * filename); unsigned char readChar(int file); -void sendEvent(struct Event * ev); inline void setPoint(struct SynthObject * so, int pt); struct Event * getEvent(struct Track * tr, int evNum); int readTwoBytes(int file); diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index b3dc40bcb1..2819c12a6a 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c @@ -271,49 +271,52 @@ void releaseNote(int ch, int note) } } -void sendEvent(struct Event * ev) +static void sendEvent(struct Event * ev) { - if( ((ev->status & 0xF0) == MIDI_CONTROL) && (ev->d1 == CTRL_VOLUME) ) + const unsigned char status_low = ev->status & 0x0F; + const unsigned char d1 = ev->d1; + const unsigned char d2 = ev->d2; + switch(ev->status & 0xF0) { - setVol((ev->status & 0xF), ev->d2); - return; - } - - if( ((ev->status & 0xF0) == MIDI_CONTROL) && (ev->d1 == CTRL_PANNING)) - { - setPan((ev->status & 0xF), ev->d2); - return; - } - - if(((ev->status & 0xF0) == MIDI_PITCHW)) - { - setPW((ev->status & 0xF), ev->d2, ev->d1); - return; - } - - if(((ev->status & 0xF0) == MIDI_NOTE_ON) && (ev->d2 != 0)) - { - pressNote(ev->status & 0x0F, ev->d1, ev->d2); - return; - } + case MIDI_CONTROL: + switch(d1) + { + case CTRL_VOLUME: + { + setVol((status_low), d2); + return; + } + case CTRL_PANNING: + { + setPan((status_low), d2); + return; + } + } + break; - if(((ev->status & 0xF0) == MIDI_NOTE_ON) && (ev->d2 == 0)) /* Release by vol=0 */ - { - releaseNote(ev->status & 0x0F, ev->d1); - return; - } + case MIDI_PITCHW: + setPW((status_low), d2, d1); + return; + case MIDI_NOTE_ON: + switch(d2) + { + case 0: /* Release by vol=0 */ + releaseNote(status_low, d1); + return; + + default: + pressNote(status_low, d1, d2); + return; + } - if((ev->status & 0xF0) == MIDI_NOTE_OFF) - { - releaseNote(ev->status & 0x0F, ev->d1); - return; - } + case MIDI_NOTE_OFF: + releaseNote(status_low, d1); + return; - if((ev->status & 0xF0) == MIDI_PRGM) - { - if((ev->status & 0x0F) != 9) - setPatch(ev->status & 0x0F, ev->d1); + case MIDI_PRGM: + if((status_low) != 9) + setPatch(status_low, d1); } } |