From 65331f17497d132c03ad48be90322d24c20d6415 Mon Sep 17 00:00:00 2001 From: Nils Wallménius Date: Thu, 15 Nov 2007 21:20:29 +0000 Subject: Revert some changes that broke looping in midiplayer git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15631 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/midi/midiutil.h | 2 +- apps/plugins/midi/sequencer.c | 1 + apps/plugins/midi/synth.c | 40 ++++++++++++++++++++++------------------ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h index f26f1208e3..18d493b23a 100644 --- a/apps/plugins/midi/midiutil.h +++ b/apps/plugins/midi/midiutil.h @@ -109,7 +109,7 @@ struct SynthObject int delta; int decay; unsigned int cp; /* unsigned int */ - int state; + int state, loopState; int note, vol, ch; int curRate, curOffset, targetOffset; int curPoint; diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index 7847c375ba..bd2f33b365 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c @@ -227,6 +227,7 @@ inline void pressNote(int ch, int note, int vol) setVolScale(a); + voices[a].loopState=STATE_NONLOOPING; /* * OKAY. Gt = Gus Table value * rf = Root Frequency of wave diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index b2efce1f7d..f9af4876fd 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c @@ -316,29 +316,33 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); - if(mode_mask28 && cp_temp >= end_loop) + if(mode_mask28) { - if(!mode_mask24) + /* LOOP_REVERSE|LOOP_PINGPONG = 24 */ + if(mode_mask24 && so->loopState == STATE_LOOPING && (cp_temp < start_loop)) { - cp_temp -= diff_loop; - s2=getSample((cp_temp >> FRACTSIZE), wf); + if(mode_mask_looprev) + { + cp_temp += diff_loop; + s2=getSample((cp_temp >> FRACTSIZE), wf); + } + else + { + so->delta = -so->delta; /* At this point cp_temp is wrong. We need to take a step */ + } } - else - { - so->delta = -so->delta; - /* LOOP_REVERSE|LOOP_PINGPONG = 24 */ - if(cp_temp < start_loop) /* this appears to never be true in here */ + if(cp_temp >= end_loop) + { + so->loopState = STATE_LOOPING; + if(!mode_mask24) { - if(mode_mask_looprev) - { - cp_temp += diff_loop; - s2=getSample((cp_temp >> FRACTSIZE), wf); - } - else - { - so->delta = -so->delta; /* At this point cp_temp is wrong. We need to take a step */ - } + cp_temp -= diff_loop; + s2=getSample((cp_temp >> FRACTSIZE), wf); + } + else + { + so->delta = -so->delta; } } } -- cgit v1.2.3