1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Nils Wallménius 2007-09-27 18:29:50 +00:00
parent 5ec5f8abac
commit 93787dd42c
3 changed files with 48 additions and 39 deletions

View file

@ -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

View file

@ -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);

View file

@ -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);
case MIDI_CONTROL:
switch(d1)
{
case CTRL_VOLUME:
{
setVol((status_low), d2);
return;
}
case CTRL_PANNING:
{
setPan((status_low), d2);
return;
}
}
break;
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_CONTROL) && (ev->d1 == CTRL_PANNING))
{
setPan((ev->status & 0xF), ev->d2);
case MIDI_NOTE_OFF:
releaseNote(status_low, d1);
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;
}
if(((ev->status & 0xF0) == MIDI_NOTE_ON) && (ev->d2 == 0)) /* Release by vol=0 */
{
releaseNote(ev->status & 0x0F, ev->d1);
return;
}
if((ev->status & 0xF0) == MIDI_NOTE_OFF)
{
releaseNote(ev->status & 0x0F, ev->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);
}
}