summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/synth.c
diff options
context:
space:
mode:
authorStepan Moskovchenko <stevenm@rockbox.org>2007-09-27 03:59:33 +0000
committerStepan Moskovchenko <stevenm@rockbox.org>2007-09-27 03:59:33 +0000
commit8b6d28790ee9e546e48616afbb622246c0962c79 (patch)
tree853f5cc7780ba06c1aed199d8d62ff3b6640bcb4 /apps/plugins/midi/synth.c
parent61a83c02a3f0812c54cc9c41d2c1002af4c63f9e (diff)
downloadrockbox-8b6d28790ee9e546e48616afbb622246c0962c79.tar.gz
rockbox-8b6d28790ee9e546e48616afbb622246c0962c79.zip
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
Diffstat (limited to 'apps/plugins/midi/synth.c')
-rw-r--r--apps/plugins/midi/synth.c41
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)