diff options
Diffstat (limited to 'apps/plugins/midi/midiplay.c')
-rw-r--r-- | apps/plugins/midi/midiplay.c | 58 |
1 files changed, 4 insertions, 54 deletions
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c index c69c8b1ad6..cc8746308f 100644 --- a/apps/plugins/midi/midiplay.c +++ b/apps/plugins/midi/midiplay.c | |||
@@ -108,7 +108,6 @@ int numberOfSamples IBSS_ATTR; /* the number of samples in the current tick */ | |||
108 | int playingTime IBSS_ATTR; /* How many seconds into the file have we been playing? */ | 108 | int playingTime IBSS_ATTR; /* How many seconds into the file have we been playing? */ |
109 | int samplesThisSecond IBSS_ATTR; /* How many samples produced during this second so far? */ | 109 | int samplesThisSecond IBSS_ATTR; /* How many samples produced during this second so far? */ |
110 | 110 | ||
111 | |||
112 | long bpm IBSS_ATTR; | 111 | long bpm IBSS_ATTR; |
113 | 112 | ||
114 | int32_t gmbuf[BUF_SIZE*NBUF]; | 113 | int32_t gmbuf[BUF_SIZE*NBUF]; |
@@ -123,6 +122,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
123 | { | 122 | { |
124 | int retval = 0; | 123 | int retval = 0; |
125 | 124 | ||
125 | |||
126 | PLUGIN_IRAM_INIT(api) | 126 | PLUGIN_IRAM_INIT(api) |
127 | 127 | ||
128 | rb = api; | 128 | rb = api; |
@@ -317,66 +317,16 @@ static int midimain(void * filename) | |||
317 | /* Rewinding is tricky. Basically start the file over */ | 317 | /* Rewinding is tricky. Basically start the file over */ |
318 | /* but run through the tracks without the synth running */ | 318 | /* but run through the tracks without the synth running */ |
319 | rb->pcm_play_stop(); | 319 | rb->pcm_play_stop(); |
320 | 320 | seekBackward(5); | |
321 | int desiredTime = playingTime - 5; /* Rewind 5 sec */ | ||
322 | |||
323 | if(desiredTime < 0) | ||
324 | desiredTime = 0; | ||
325 | |||
326 | /* Set controllers to default values */ | ||
327 | resetControllers(); | ||
328 | |||
329 | /* Set the tempo to defalt */ | ||
330 | bpm=mf->div*1000000/tempo; | ||
331 | numberOfSamples=SAMPLE_RATE/bpm; | ||
332 | |||
333 | |||
334 | /* Reset the tracks to start */ | ||
335 | rewindFile(); | ||
336 | |||
337 | /* Reset the time counter to 0 */ | ||
338 | playingTime = 0; | ||
339 | samplesThisSecond = 0; | ||
340 | |||
341 | /* Quickly run through any initial things that occur before notes */ | ||
342 | do | ||
343 | { | ||
344 | notesUsed = 0; | ||
345 | for(a=0; a<MAX_VOICES; a++) | ||
346 | if(voices[a].isUsed == 1) | ||
347 | notesUsed++; | ||
348 | tick(); | ||
349 | } while(notesUsed == 0); | ||
350 | |||
351 | /* Reset the time counter to 0 */ | ||
352 | playingTime = 0; | ||
353 | samplesThisSecond = 0; | ||
354 | |||
355 | |||
356 | |||
357 | /* Tick until goal is reached */ | ||
358 | while(playingTime < desiredTime) | ||
359 | tick(); | ||
360 | |||
361 | rb->pcm_play_data(&get_more, NULL, 0); | 321 | rb->pcm_play_data(&get_more, NULL, 0); |
322 | |||
362 | break; | 323 | break; |
363 | } | 324 | } |
364 | 325 | ||
365 | case BTN_RIGHT: | 326 | case BTN_RIGHT: |
366 | { | 327 | { |
367 | /* Skip 5 seconds forward */ | ||
368 | /* Skipping forward is easy */ | ||
369 | /* Should skip length be retrieved from the RB settings? */ | ||
370 | int samp = 5*SAMPLE_RATE; | ||
371 | |||
372 | /* Have the issue where numberOfSamples changes within this tick */ | ||
373 | int tickCount = samp / numberOfSamples; | ||
374 | int a=0; | ||
375 | |||
376 | rb->pcm_play_stop(); | 328 | rb->pcm_play_stop(); |
377 | 329 | seekForward(5); | |
378 | for(a=0; a<tickCount; a++) | ||
379 | tick(); | ||
380 | rb->pcm_play_data(&get_more, NULL, 0); | 330 | rb->pcm_play_data(&get_more, NULL, 0); |
381 | break; | 331 | break; |
382 | } | 332 | } |