From 2482447f98d3c0ec5899476d6b766e7fe1d1b86f Mon Sep 17 00:00:00 2001 From: bsutherland Date: Thu, 15 Jan 2015 12:07:49 +0900 Subject: [PATCH] Fix some percussion recording issues. --- JuceOPLVSTi.jucer | 2 +- Source/DROMultiplexer.cpp | 20 +++++++++----------- Source/PluginProcessor.cpp | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/JuceOPLVSTi.jucer b/JuceOPLVSTi.jucer index 5ec1808..942e45b 100644 --- a/JuceOPLVSTi.jucer +++ b/JuceOPLVSTi.jucer @@ -75,7 +75,7 @@ + externalLibraries="" toolset="v120_xp"> diff --git a/Source/DROMultiplexer.cpp b/Source/DROMultiplexer.cpp index 7468be0..8292c83 100644 --- a/Source/DROMultiplexer.cpp +++ b/Source/DROMultiplexer.cpp @@ -67,7 +67,7 @@ static Bit32u CHANNEL_OFFSETS[15]= { // bass drum uses two operators. // others use either modulator or carrier. static Bit32u PERCUSSION_OPERATORS[5][2] = { - { 0x10, 0x13 }, // bd + { 0x13, 0x10 }, // bd { 0x00, 0x14 }, // sd { 0x12, 0x00 }, // tt { 0x00, 0x15}, // cy @@ -145,7 +145,7 @@ void DROMultiplexer::_CopyOplPercussionSettings(Hiopl* opl, int pIdx) { int chInOff = opl->_GetOffset(1); inAddr = 0xc0 + chInOff; outAddr = 0xc0 + PERCUSSION_CHANNELS[pIdx]; - _CaptureRegWrite(outAddr, 0x30 | opl->_ReadReg(inAddr)); + _CaptureRegWrite(outAddr, 0x30 | opl->_ReadReg(inAddr)); // make sure L+R channels always enabled } void DROMultiplexer::_CopyOplChannelSettings(Hiopl* opl, int inCh, int outCh) { @@ -256,12 +256,11 @@ void DROMultiplexer::PercussionChange(Hiopl* opl, int pIdx) { const ScopedLock sl(lock); _CopyOplPercussionSettings(opl, pIdx); Bit8u val = opl->_ReadReg(0xbd); - Bit8u masked = 0x1f & val; - if (0 == masked) { // note-off - // TODO: clear the correct bit only - _CaptureRegWriteWithDelay(0xbd, val & 0xe0); - } else { // note-on - _CaptureRegWriteWithDelay(0xbd, OxBD | masked); + Bit8u maskOut = 1 << abs(4 - pIdx); + if (0 == (val & maskOut)) { // note-off + _CaptureRegWriteWithDelay(0xbd, 0xBD & (0xe0 | ~maskOut)); + } else { // note-on + _CaptureRegWriteWithDelay(0xbd, OxBD | maskOut); } } @@ -275,7 +274,7 @@ void DROMultiplexer::InitCaptureVariables() { channels[i].opl = NULL; channels[i].ch = -1; } - OxBD = 0x0; + OxBD = 0x20; // percussion mode should always be enabled } bool DROMultiplexer::StartCapture(const char* filepath, Hiopl *opl) { @@ -302,8 +301,7 @@ bool DROMultiplexer::StartCapture(const char* filepath, Hiopl *opl) { for (Bit8u i = 0x80; i <= 0x95; i++) { _CaptureRegWrite(i, opl->_ReadReg(i)); } - _CaptureRegWrite(0xbd, opl->_ReadReg(0xbd)); - OxBD = opl->_ReadReg(0xbd); + _CaptureRegWrite(0xbd, OxBD | (opl->_ReadReg(0xbd) & 0xc0)); // enable percmode, copy tremolo and vibrato depth only for (Bit8u i = 0xc0; i <= 0xc8; i++) { _CaptureRegWrite(i, opl->_ReadReg(i) | 0x30); // enable L + R channels } diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 54e071d..d44de01 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -732,7 +732,7 @@ void JuceOplvstiAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuf } Opl->HitPercussion(DRUM_INDEX[perc - 1]); if (isAnyInstanceRecording()) { - dro->GetMaster()->PercussionChange(Opl, perc); + dro->GetMaster()->PercussionChange(Opl, perc - 1); } } else { if (!available_channels.empty()) @@ -783,7 +783,7 @@ void JuceOplvstiAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuf if (perc > 0) { Opl->ReleasePercussion(); if (isAnyInstanceRecording()) { - dro->GetMaster()->PercussionChange(Opl, perc-1); + dro->GetMaster()->PercussionChange(Opl, perc - 1); } } else {