From 60f7ea56a4ccc88a8e747b87ba9fb39f1d8330b5 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 24 Jun 2018 21:46:38 +0300 Subject: [Experimental] Big re-factoring of internals and clean-up - Renamed functions - Renamed variables - Documenting of most library internal stuff - Disabling of embedded banks no more conflicts with accidental linking of adldata.cpp --- src/adlmidi_private.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/adlmidi_private.cpp') diff --git a/src/adlmidi_private.cpp b/src/adlmidi_private.cpp index 3bc73a4..8d7b9a7 100644 --- a/src/adlmidi_private.cpp +++ b/src/adlmidi_private.cpp @@ -40,11 +40,13 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); //Automatically calculate how much 4-operator channels is necessary - if(play->opl.AdlBank == ~0u) +#ifndef DISABLE_EMBEDDED_BANKS + if(play->m_synth.m_embeddedBank == ~0u) +#endif { //For custom bank - OPL3::BankMap::iterator it = play->opl.dynamic_banks.begin(); - OPL3::BankMap::iterator end = play->opl.dynamic_banks.end(); + OPL3::BankMap::iterator it = play->m_synth.m_insBanks.begin(); + OPL3::BankMap::iterator end = play->m_synth.m_insBanks.end(); for(; it != end; ++it) { uint16_t bank = it->first; @@ -60,12 +62,13 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) } } } +#ifndef DISABLE_EMBEDDED_BANKS else { //For embedded bank for(unsigned a = 0; a < 256; ++a) { - unsigned insno = banks[play->m_setup.AdlBank][a]; + unsigned insno = banks[play->m_setup.bankId][a]; if(insno == 198) continue; ++n_total[a / 128]; @@ -74,6 +77,7 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) ++n_fourop[a / 128]; } } +#endif unsigned numFourOps = 0; @@ -96,7 +100,7 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) : (play->m_setup.NumCards == 1 ? 1 : play->m_setup.NumCards * 4); */ - play->opl.NumFourOps = play->m_setup.NumFourOps = (numFourOps * play->m_setup.NumCards); + play->m_synth.m_numFourOps = play->m_setup.numFourOps = (numFourOps * play->m_setup.numChips); return 0; } -- cgit v1.2.3 From 744bf587fd7f117ba4884fe3406be4237dd92a8c Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Mon, 25 Jun 2018 03:04:33 +0300 Subject: Using bigger integers for math in some places --- src/adlmidi_private.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/adlmidi_private.cpp') diff --git a/src/adlmidi_private.cpp b/src/adlmidi_private.cpp index 8d7b9a7..8e7d260 100644 --- a/src/adlmidi_private.cpp +++ b/src/adlmidi_private.cpp @@ -36,12 +36,12 @@ void adl_audioTickHandler(void *instance, uint32_t chipId, uint32_t rate) int adlRefreshNumCards(ADL_MIDIPlayer *device) { - unsigned n_fourop[2] = {0, 0}, n_total[2] = {0, 0}; + size_t n_fourop[2] = {0, 0}, n_total[2] = {0, 0}; MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); //Automatically calculate how much 4-operator channels is necessary #ifndef DISABLE_EMBEDDED_BANKS - if(play->m_synth.m_embeddedBank == ~0u) + if(play->m_synth.m_embeddedBank == OPL3::CustomBankTag) #endif { //For custom bank @@ -49,9 +49,9 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) OPL3::BankMap::iterator end = play->m_synth.m_insBanks.end(); for(; it != end; ++it) { - uint16_t bank = it->first; - unsigned div = (bank & OPL3::PercussionTag) ? 1 : 0; - for(unsigned i = 0; i < 128; ++i) + size_t bank = it->first; + size_t div = (bank & OPL3::PercussionTag) ? 1 : 0; + for(size_t i = 0; i < 128; ++i) { adlinsdata2 &ins = it->second.ins[i]; if(ins.flags & adlinsdata::Flag_NoSound) @@ -66,9 +66,9 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) else { //For embedded bank - for(unsigned a = 0; a < 256; ++a) + for(size_t a = 0; a < 256; ++a) { - unsigned insno = banks[play->m_setup.bankId][a]; + size_t insno = banks[play->m_setup.bankId][a]; if(insno == 198) continue; ++n_total[a / 128]; @@ -79,7 +79,7 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) } #endif - unsigned numFourOps = 0; + size_t numFourOps = 0; // All 2ops (no 4ops) if((n_fourop[0] == 0) && (n_fourop[1] == 0)) @@ -100,7 +100,7 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) : (play->m_setup.NumCards == 1 ? 1 : play->m_setup.NumCards * 4); */ - play->m_synth.m_numFourOps = play->m_setup.numFourOps = (numFourOps * play->m_setup.numChips); + play->m_synth.m_numFourOps = play->m_setup.numFourOps = static_cast(numFourOps * play->m_setup.numChips); return 0; } -- cgit v1.2.3 From ef601741e585f7b48c2fe81304bcba4d161ed375 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Mon, 25 Jun 2018 14:51:00 +0300 Subject: Fixed missing refresh of 4-op channels count --- src/adlmidi_private.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/adlmidi_private.cpp') diff --git a/src/adlmidi_private.cpp b/src/adlmidi_private.cpp index 8e7d260..ecedd9e 100644 --- a/src/adlmidi_private.cpp +++ b/src/adlmidi_private.cpp @@ -101,6 +101,8 @@ int adlRefreshNumCards(ADL_MIDIPlayer *device) */ play->m_synth.m_numFourOps = play->m_setup.numFourOps = static_cast(numFourOps * play->m_setup.numChips); + // Update channel categories and set up four-operator channels + play->m_synth.updateChannelCategories(); return 0; } -- cgit v1.2.3