diff options
Diffstat (limited to 'apps/plugins/midi/sequencer.c')
-rw-r--r-- | apps/plugins/midi/sequencer.c | 71 |
1 files changed, 63 insertions, 8 deletions
diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index b9cc83f9ad..4e6c15fba6 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c | |||
@@ -142,7 +142,6 @@ const uint32_t pitchTbl[] ICONST_ATTR={ | |||
142 | 142 | ||
143 | static void findDelta(struct SynthObject * so, int ch, int note) | 143 | static void findDelta(struct SynthObject * so, int ch, int note) |
144 | { | 144 | { |
145 | |||
146 | struct GWaveform * wf = patchSet[chPat[ch]]->waveforms[patchSet[chPat[ch]]->noteTable[note]]; | 145 | struct GWaveform * wf = patchSet[chPat[ch]]->waveforms[patchSet[chPat[ch]]->noteTable[note]]; |
147 | so->wf=wf; | 146 | so->wf=wf; |
148 | unsigned int delta= 0; | 147 | unsigned int delta= 0; |
@@ -152,14 +151,8 @@ static void findDelta(struct SynthObject * so, int ch, int note) | |||
152 | so->delta = delta; | 151 | so->delta = delta; |
153 | } | 152 | } |
154 | 153 | ||
155 | static inline void setPW(int ch, int msb, int lsb) | 154 | static inline void computeDeltas(int ch) |
156 | { | 155 | { |
157 | chPW[ch] = msb<<2|lsb>>5; | ||
158 | |||
159 | int totalBend = (chPW[ch]-256) * chPBDepth[ch]; | ||
160 | chPBNoteOffset[ch] = totalBend >> 8; | ||
161 | chPBFractBend[ch] = pitchTbl[(totalBend & 0xFF) + 256]; | ||
162 | |||
163 | int a=0; | 156 | int a=0; |
164 | for(a = 0; a<MAX_VOICES; a++) | 157 | for(a = 0; a<MAX_VOICES; a++) |
165 | { | 158 | { |
@@ -170,6 +163,17 @@ static inline void setPW(int ch, int msb, int lsb) | |||
170 | } | 163 | } |
171 | } | 164 | } |
172 | 165 | ||
166 | static inline void setPW(int ch, int msb, int lsb) | ||
167 | { | ||
168 | chPW[ch] = msb<<2|lsb>>5; | ||
169 | |||
170 | int totalBend = (chPW[ch]-256) * chPBDepth[ch]; | ||
171 | chPBNoteOffset[ch] = totalBend >> 8; | ||
172 | chPBFractBend[ch] = pitchTbl[(totalBend & 0xFF) + 256]; | ||
173 | |||
174 | computeDeltas(ch); | ||
175 | } | ||
176 | |||
173 | inline void pressNote(int ch, int note, int vol) | 177 | inline void pressNote(int ch, int note, int vol) |
174 | { | 178 | { |
175 | static int lastKill = 0; | 179 | static int lastKill = 0; |
@@ -376,7 +380,58 @@ void rewindFile(void) | |||
376 | } | 380 | } |
377 | } | 381 | } |
378 | 382 | ||
383 | |||
379 | int tick(void) ICODE_ATTR; | 384 | int tick(void) ICODE_ATTR; |
385 | |||
386 | void seekBackward(int nsec) | ||
387 | { | ||
388 | int notesUsed = 0, a=0; | ||
389 | int desiredTime = playingTime - nsec; /* Rewind 5 sec */ | ||
390 | |||
391 | if(desiredTime < 0) | ||
392 | desiredTime = 0; | ||
393 | |||
394 | /* Set controllers to default values */ | ||
395 | resetControllers(); | ||
396 | |||
397 | /* Set the tempo to defalt */ | ||
398 | bpm=mf->div*1000000/tempo; | ||
399 | numberOfSamples=SAMPLE_RATE/bpm; | ||
400 | |||
401 | |||
402 | /* Reset the tracks to start */ | ||
403 | rewindFile(); | ||
404 | |||
405 | /* Reset the time counter to 0 */ | ||
406 | playingTime = 0; | ||
407 | samplesThisSecond = 0; | ||
408 | |||
409 | /* Quickly run through any initial things that occur before notes */ | ||
410 | do | ||
411 | { | ||
412 | notesUsed = 0; | ||
413 | for(a=0; a<MAX_VOICES; a++) | ||
414 | if(voices[a].isUsed == 1) | ||
415 | notesUsed++; | ||
416 | tick(); | ||
417 | } while(notesUsed == 0); | ||
418 | |||
419 | /* Reset the time counter to 0 */ | ||
420 | playingTime = 0; | ||
421 | samplesThisSecond = 0; | ||
422 | |||
423 | /* Tick until goal is reached */ | ||
424 | while(playingTime < desiredTime) | ||
425 | tick(); | ||
426 | } | ||
427 | |||
428 | |||
429 | void seekForward(int nsec) | ||
430 | { | ||
431 | int desiredTime = playingTime + nsec; | ||
432 | while(tick() && playingTime < desiredTime); | ||
433 | } | ||
434 | |||
380 | int tick(void) | 435 | int tick(void) |
381 | { | 436 | { |
382 | if(mf==NULL) | 437 | if(mf==NULL) |