From 8b6d28790ee9e546e48616afbb622246c0962c79 Mon Sep 17 00:00:00 2001 From: Stepan Moskovchenko Date: Thu, 27 Sep 2007 03:59:33 +0000 Subject: Some MIDI changes, and add a new musical plugin I'm working on... Not fully done yet, so commented out of SUBDIRS. (If people are against having half-baked plugins in SVN, please let me know and I will remove it). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14863 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/midi/synth.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'apps/plugins/midi/synth.c') diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 917a8ae13d..bcfd79499b 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c @@ -88,26 +88,35 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) patchUsed[0]=1; /* Scan the file to see what needs to be loaded */ - for(a=0; anumTracks; a++) + if(mf != NULL) { - unsigned int ts=0; - - if(mf->tracks[a] == NULL) + for(a=0; anumTracks; a++) { - printf("NULL TRACK !!!"); - rb->splash(HZ*2, "Null Track in loader."); - return -1; - } + unsigned int ts=0; - for(ts=0; tstracks[a]->numEvents; ts++) - { + if(mf->tracks[a] == NULL) + { + printf("NULL TRACK !!!"); + rb->splash(HZ*2, "Null Track in loader."); + return -1; + } - if((getEvent(mf->tracks[a], ts)->status) == (MIDI_NOTE_ON+9)) - drumUsed[getEvent(mf->tracks[a], ts)->d1]=1; + for(ts=0; tstracks[a]->numEvents; ts++) + { + + if((getEvent(mf->tracks[a], ts)->status) == (MIDI_NOTE_ON+9)) + drumUsed[getEvent(mf->tracks[a], ts)->d1]=1; - if( (getEvent(mf->tracks[a], ts)->status & 0xF0) == MIDI_PRGM) - patchUsed[getEvent(mf->tracks[a], ts)->d1]=1; + if( (getEvent(mf->tracks[a], ts)->status & 0xF0) == MIDI_PRGM) + patchUsed[getEvent(mf->tracks[a], ts)->d1]=1; + } } + } else + { + /* Initialize the whole drum set */ + for(a=0; a<128; a++) + drumUsed[a]=1; + } int file = rb->open(filename, O_RDONLY); @@ -289,7 +298,7 @@ signed short int synthVoice(struct SynthObject * so) s2 = getSample((cpShifted)+1, wf); /* LOOP_REVERSE|LOOP_PINGPONG = 24 */ - if((wf->mode & (24)) && so->loopState == STATE_LOOPING && (cpShifted <= (wf->startLoop))) + if((wf->mode & (24)) && so->loopState == STATE_LOOPING && (cpShifted < (wf->startLoop))) { if(wf->mode & LOOP_REVERSE) { @@ -304,7 +313,7 @@ signed short int synthVoice(struct SynthObject * so) } } - if((wf->mode & 28) && (cpShifted >= wf->endLoop)) + if((wf->mode & 28) && (cpShifted > wf->endLoop)) { so->loopState = STATE_LOOPING; if((wf->mode & (24)) == 0) -- cgit v1.2.3