Mercurial > hg > dmlib
diff jssplr.c @ 180:bc8019c38ba5
Refactoring of the note triggering and other player logic, fixes various
issues.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 06 Oct 2012 12:51:20 +0300 |
parents | eb293aa7a671 |
children | 879b2488340a |
line wrap: on
line diff
--- a/jssplr.c Sat Oct 06 12:28:53 2012 +0300 +++ b/jssplr.c Sat Oct 06 12:51:20 2012 +0300 @@ -911,7 +911,7 @@ { chn->iLastPortaToNotePitch = chn->iCPitch; chn->iCPitch = chn->iCOldPitch; - JMPUNSETNDFLAGS(cdfNewPitch | cdfNewInstr | cdfNewPanPos); + JMPUNSETNDFLAGS(cdfNewPitch | cdfPlay); } break; @@ -1182,31 +1182,20 @@ { chn->iCExtInstrumentN = currNote->instrument; chn->iCExtInstrument = mp->module->extInstruments[currNote->instrument]; - } - } - /* ONLY if newNote was SET NOW and ExtInstrument HAS BEEN set, we can - * set new pitches, and other things... - */ - if (newNote && chn->iCExtInstrument != NULL) - { - JSSExtInstrument *extInst = chn->iCExtInstrument; - - // Get instrument number - tmp = extInst->sNumForNotes[chn->iCNote]; + // Get instrument number + tmp = chn->iCExtInstrument->sNumForNotes[chn->iCNote]; - if (tmp >= 0 && tmp < mp->module->ninstruments) - { - // Set the new instrument - JSSInstrument *inst = mp->module->instruments[tmp]; - chn->iCInstrumentN = tmp; - chn->iCInstrument = inst; - chn->iCVolume = inst->volume; - chn->iCPanning = inst->EPanning; - chn->iCPosition = 0; - - // Set NDFlags - JMPSETNDFLAGS(cdfNewInstr | cdfNewPos | cdfNewPanPos | cdfNewVolume); + if (tmp >= 0 && tmp < mp->module->ninstruments) + { + JSSInstrument *inst = mp->module->instruments[tmp]; + chn->iCInstrumentN = tmp; + chn->iCInstrument = inst; + chn->iCVolume = inst->volume; + chn->iCPanning = inst->EPanning; + chn->iCPosition = 0; + JMPSETNDFLAGS(cdfPlay | cdfNewPos | cdfNewInstr | cdfNewVolume | cdfNewPanPos); + } } } @@ -1217,10 +1206,12 @@ // Save old pitch for later use chn->iCOldPitch = chn->iCPitch; + chn->iCPosition = 0; + // Compute new pitch tmp = dmClamp(chn->iCNote + inst->ERelNote, 0, 119); chn->iCPitch = jmpGetPeriodFromNote(mp, tmp, inst->EFineTune); - JMPSETNDFLAGS(cdfNewPitch); + JMPSETNDFLAGS(cdfNewPitch | cdfPlay | cdfNewPos); } // Process the volume column @@ -1261,7 +1252,7 @@ { chn->iLastPortaToNotePitch = chn->iCPitch; chn->iCPitch = chn->iCOldPitch; - JMPUNSETNDFLAGS(cdfNewPitch | cdfNewInstr | cdfNewPanPos); + JMPUNSETNDFLAGS(cdfNewPitch | cdfPlay); } break; } @@ -1542,8 +1533,10 @@ instr->loopS, instr->loopE, instr->flags); } + } + + if (flags & cdfPlay) jvmPlay(mp->device, channel); - } if (flags & cdfNewPitch) jmpCSetPitch(mp, channel, chn->iCPitch);