diff options
-rw-r--r-- | src/adlmidi_cvt.hpp | 16 | ||||
-rw-r--r-- | src/adlmidi_opl3.cpp | 48 | ||||
-rw-r--r-- | src/adlmidi_private.cpp | 10 |
3 files changed, 7 insertions, 67 deletions
diff --git a/src/adlmidi_cvt.hpp b/src/adlmidi_cvt.hpp index 3b2e07d..74b9f78 100644 --- a/src/adlmidi_cvt.hpp +++ b/src/adlmidi_cvt.hpp @@ -78,17 +78,11 @@ static void cvt_FMIns_to_generic(WOPLI &ins, const adlinsdata2 &in) double voice2_fine_tune = in.voice2_fine_tune; if(voice2_fine_tune != 0) { - if(voice2_fine_tune > 0 && voice2_fine_tune <= 0.000025) - ins.second_voice_detune = 1; - else if(voice2_fine_tune < 0 && voice2_fine_tune >= -0.000025) - ins.second_voice_detune = -1; - else - { - long value = static_cast<long>(round(voice2_fine_tune * (1000.0 / 15.625))); - value = (value < -128) ? -128 : value; - value = (value > +127) ? +127 : value; - ins.second_voice_detune = static_cast<int8_t>(value); - } + int m = (int)(voice2_fine_tune * 32.0); + m += 64; + m <<= 1; + m -= 128; + ins.second_voice_detune = (uint8_t)m; } ins.midi_velocity_offset = in.midi_velocity_offset; diff --git a/src/adlmidi_opl3.cpp b/src/adlmidi_opl3.cpp index 7938710..9920ab8 100644 --- a/src/adlmidi_opl3.cpp +++ b/src/adlmidi_opl3.cpp @@ -324,58 +324,10 @@ void OPL3::setEmbeddedBank(uint32_t bank) adlinsdata2 &instOut = bankTarget.ins[instId]; adlFromInstrument(instIn, instOut); - -// instOut.voice2_fine_tune = 0.0; -// if(instIn.secondVoiceDetune != 0) -// { -// if(instIn.secondVoiceDetune == 1) -// instOut.voice2_fine_tune = 0.000025; -// else if(instIn.secondVoiceDetune == -1) -// instOut.voice2_fine_tune = -0.000025; -// else -// instOut.voice2_fine_tune = instIn.secondVoiceDetune * (15.625 / 1000.0); -// } - -// instOut.midi_velocity_offset = instIn.midiVelocityOffset; -// instOut.tone = instIn.percussionKeyNumber; -// instOut.flags = (instIn.instFlags & WOPL_Ins_4op) && (instIn.instFlags & WOPL_Ins_Pseudo4op) ? adlinsdata::Flag_Pseudo4op : 0; -// instOut.flags|= (instIn.instFlags & WOPL_Ins_4op) && ((instIn.instFlags & WOPL_Ins_Pseudo4op) == 0) ? adlinsdata::Flag_Real4op : 0; -// instOut.flags|= (instIn.instFlags & WOPL_Ins_IsBlank) ? adlinsdata::Flag_NoSound : 0; -// instOut.flags|= instIn.instFlags & WOPL_RhythmModeMask; - -// for(size_t op = 0; op < 2; op++) -// { -// if((instIn.ops[(op * 2) + 0] < 0) || (instIn.ops[(op * 2) + 1] < 0)) -// break; -// const BanksDump::Operator &op1 = g_embeddedBanksOperators[instIn.ops[(op * 2) + 0]]; -// const BanksDump::Operator &op2 = g_embeddedBanksOperators[instIn.ops[(op * 2) + 1]]; -// instOut.adl[op].modulator_E862 = op1.d_E862; -// instOut.adl[op].modulator_40 = op1.d_40; -// instOut.adl[op].carrier_E862 = op2.d_E862; -// instOut.adl[op].carrier_40 = op2.d_40; -// instOut.adl[op].feedconn = (instIn.fbConn >> (op * 8)) & 0xFF; -// instOut.adl[op].finetune = static_cast<int8_t>(op == 0 ? instIn.noteOffset1 : instIn.noteOffset2); -// } -// instOut.ms_sound_kon = instIn.delay_on_ms; -// instOut.ms_sound_koff = instIn.delay_off_ms; } } } -// Bank *bank_pair[2] = -// { -// &m_insBanks[0], -// &m_insBanks[PercussionTag] -// }; - -// for(unsigned i = 0; i < 256; ++i) -// { -// size_t meta = banks[bank][i]; -// adlinsdata2 &ins = bank_pair[i / 128]->ins[i % 128]; -// ins = adlinsdata2::from_adldata(::adlins[meta]); -// } - - #else ADL_UNUSED(bank); #endif diff --git a/src/adlmidi_private.cpp b/src/adlmidi_private.cpp index ac2b496..9478236 100644 --- a/src/adlmidi_private.cpp +++ b/src/adlmidi_private.cpp @@ -126,14 +126,7 @@ void adlFromInstrument(const BanksDump::InstrumentEntry &instIn, adlinsdata2 &in { instOut.voice2_fine_tune = 0.0; if(instIn.secondVoiceDetune != 0) - { - if(instIn.secondVoiceDetune == 1) - instOut.voice2_fine_tune = 0.000025; - else if(instIn.secondVoiceDetune == -1) - instOut.voice2_fine_tune = -0.000025; - else - instOut.voice2_fine_tune = instIn.secondVoiceDetune * (15.625 / 1000.0); - } + instOut.voice2_fine_tune = (double)((((int)instIn.secondVoiceDetune + 128) >> 1) - 64) / 32.0; instOut.midi_velocity_offset = instIn.midiVelocityOffset; instOut.tone = instIn.percussionKeyNumber; @@ -155,6 +148,7 @@ void adlFromInstrument(const BanksDump::InstrumentEntry &instIn, adlinsdata2 &in instOut.adl[op].feedconn = (instIn.fbConn >> (op * 8)) & 0xFF; instOut.adl[op].finetune = static_cast<int8_t>(op == 0 ? instIn.noteOffset1 : instIn.noteOffset2); } + instOut.ms_sound_kon = instIn.delay_on_ms; instOut.ms_sound_koff = instIn.delay_off_ms; } |