diff options
Diffstat (limited to 'apps/plugins/midi/synth.c')
-rw-r--r-- | apps/plugins/midi/synth.c | 41 |
1 files changed, 25 insertions, 16 deletions
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) | |||
88 | patchUsed[0]=1; | 88 | patchUsed[0]=1; |
89 | 89 | ||
90 | /* Scan the file to see what needs to be loaded */ | 90 | /* Scan the file to see what needs to be loaded */ |
91 | for(a=0; a<mf->numTracks; a++) | 91 | if(mf != NULL) |
92 | { | 92 | { |
93 | unsigned int ts=0; | 93 | for(a=0; a<mf->numTracks; a++) |
94 | |||
95 | if(mf->tracks[a] == NULL) | ||
96 | { | 94 | { |
97 | printf("NULL TRACK !!!"); | 95 | unsigned int ts=0; |
98 | rb->splash(HZ*2, "Null Track in loader."); | ||
99 | return -1; | ||
100 | } | ||
101 | 96 | ||
102 | for(ts=0; ts<mf->tracks[a]->numEvents; ts++) | 97 | if(mf->tracks[a] == NULL) |
103 | { | 98 | { |
99 | printf("NULL TRACK !!!"); | ||
100 | rb->splash(HZ*2, "Null Track in loader."); | ||
101 | return -1; | ||
102 | } | ||
104 | 103 | ||
105 | if((getEvent(mf->tracks[a], ts)->status) == (MIDI_NOTE_ON+9)) | 104 | for(ts=0; ts<mf->tracks[a]->numEvents; ts++) |
106 | drumUsed[getEvent(mf->tracks[a], ts)->d1]=1; | 105 | { |
106 | |||
107 | if((getEvent(mf->tracks[a], ts)->status) == (MIDI_NOTE_ON+9)) | ||
108 | drumUsed[getEvent(mf->tracks[a], ts)->d1]=1; | ||
107 | 109 | ||
108 | if( (getEvent(mf->tracks[a], ts)->status & 0xF0) == MIDI_PRGM) | 110 | if( (getEvent(mf->tracks[a], ts)->status & 0xF0) == MIDI_PRGM) |
109 | patchUsed[getEvent(mf->tracks[a], ts)->d1]=1; | 111 | patchUsed[getEvent(mf->tracks[a], ts)->d1]=1; |
112 | } | ||
110 | } | 113 | } |
114 | } else | ||
115 | { | ||
116 | /* Initialize the whole drum set */ | ||
117 | for(a=0; a<128; a++) | ||
118 | drumUsed[a]=1; | ||
119 | |||
111 | } | 120 | } |
112 | 121 | ||
113 | int file = rb->open(filename, O_RDONLY); | 122 | int file = rb->open(filename, O_RDONLY); |
@@ -289,7 +298,7 @@ signed short int synthVoice(struct SynthObject * so) | |||
289 | s2 = getSample((cpShifted)+1, wf); | 298 | s2 = getSample((cpShifted)+1, wf); |
290 | 299 | ||
291 | /* LOOP_REVERSE|LOOP_PINGPONG = 24 */ | 300 | /* LOOP_REVERSE|LOOP_PINGPONG = 24 */ |
292 | if((wf->mode & (24)) && so->loopState == STATE_LOOPING && (cpShifted <= (wf->startLoop))) | 301 | if((wf->mode & (24)) && so->loopState == STATE_LOOPING && (cpShifted < (wf->startLoop))) |
293 | { | 302 | { |
294 | if(wf->mode & LOOP_REVERSE) | 303 | if(wf->mode & LOOP_REVERSE) |
295 | { | 304 | { |
@@ -304,7 +313,7 @@ signed short int synthVoice(struct SynthObject * so) | |||
304 | } | 313 | } |
305 | } | 314 | } |
306 | 315 | ||
307 | if((wf->mode & 28) && (cpShifted >= wf->endLoop)) | 316 | if((wf->mode & 28) && (cpShifted > wf->endLoop)) |
308 | { | 317 | { |
309 | so->loopState = STATE_LOOPING; | 318 | so->loopState = STATE_LOOPING; |
310 | if((wf->mode & (24)) == 0) | 319 | if((wf->mode & (24)) == 0) |