diff options
author | Wohlstand <admin@wohlnet.ru> | 2017-10-17 21:00:59 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2017-10-17 21:00:59 +0300 |
commit | 8b88c5ce46c508f5b7277774456b2266d459cc88 (patch) | |
tree | 735af1af14ce047ae72c548fc1c703552f712e8f /src | |
parent | c07b146a1a3991edd6c3233dcd1956b989303dd3 (diff) | |
download | libADLMIDI-8b88c5ce46c508f5b7277774456b2266d459cc88.tar.gz libADLMIDI-8b88c5ce46c508f5b7277774456b2266d459cc88.tar.bz2 libADLMIDI-8b88c5ce46c508f5b7277774456b2266d459cc88.zip |
Custom banks 4-operator voices playback fix
Diffstat (limited to 'src')
-rw-r--r-- | src/adlmidi_opl3.cpp | 4 | ||||
-rw-r--r-- | src/adlmidi_private.cpp | 36 | ||||
-rw-r--r-- | src/adlmidi_private.hpp | 1 | ||||
-rw-r--r-- | src/midiplay/adlmidiplay.cpp | 2 |
4 files changed, 29 insertions, 14 deletions
diff --git a/src/adlmidi_opl3.cpp b/src/adlmidi_opl3.cpp index 27680f5..7ae2486 100644 --- a/src/adlmidi_opl3.cpp +++ b/src/adlmidi_opl3.cpp @@ -321,7 +321,6 @@ void OPL3::updateFlags() { for(unsigned b = 0; b < 5; ++b) four_op_category[a * 23 + 18 + b] = static_cast<char>(b + 3); - for(unsigned b = 0; b < 3; ++b) four_op_category[a * 23 + 6 + b] = 8; } @@ -339,16 +338,13 @@ void OPL3::updateFlags() case 1: nextfour += 1; break; - case 2: nextfour += 9 - 2; break; - case 3: case 4: nextfour += 1; break; - case 5: nextfour += 23 - 9 - 2; break; diff --git a/src/adlmidi_private.cpp b/src/adlmidi_private.cpp index 0c18958..fd9253c 100644 --- a/src/adlmidi_private.cpp +++ b/src/adlmidi_private.cpp @@ -28,24 +28,40 @@ std::string ADLMIDI_ErrorString; int adlRefreshNumCards(ADL_MIDIPlayer *device) { unsigned n_fourop[2] = {0, 0}, n_total[2] = {0, 0}; + MIDIplay *play = reinterpret_cast<MIDIplay *>(device->adl_midiPlayer); - for(unsigned a = 0; a < 256; ++a) + //Automatically calculate how much 4-operator channels is necessary + if(play->opl.AdlBank == ~0u) { - unsigned insno = banks[device->AdlBank][a]; - - if(insno == 198) continue; - - ++n_total[a / 128]; - - if(adlins[insno].adlno1 != adlins[insno].adlno2) - ++n_fourop[a / 128]; + //For custom bank + for(size_t a = 0; a < play->opl.dynamic_metainstruments.size(); ++a) + { + ++n_total[a / 128]; + adlinsdata &ins = play->opl.dynamic_metainstruments[a]; + if((ins.adlno1 != ins.adlno2) && ((ins.flags & adlinsdata::Flag_Pseudo4op) == 0)) + ++n_fourop[a / 128]; + } + } + else + { + //For embedded bank + for(unsigned a = 0; a < 256; ++a) + { + unsigned insno = banks[device->AdlBank][a]; + if(insno == 198) + continue; + ++n_total[a / 128]; + const adlinsdata &ins = adlins[insno]; + if((ins.adlno1 != ins.adlno2) && ((ins.flags & adlinsdata::Flag_Pseudo4op) == 0)) + ++n_fourop[a / 128]; + } } device->NumFourOps = (n_fourop[0] >= n_total[0] * 7 / 8) ? device->NumCards * 6 : (n_fourop[0] < n_total[0] * 1 / 8) ? 0 : (device->NumCards == 1 ? 1 : device->NumCards * 4); - reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.NumFourOps = device->NumFourOps; + play->opl.NumFourOps = device->NumFourOps; if(n_fourop[0] >= n_total[0] * 15 / 16 && device->NumFourOps == 0) { diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 17863d3..7bb5774 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -121,6 +121,7 @@ private: std::vector<uint8_t> pit; // value poked to B0, cached, needed by NoteOff)( std::vector<uint8_t> regBD; + friend int adlRefreshNumCards(ADL_MIDIPlayer *device); std::vector<adlinsdata> dynamic_metainstruments; // Replaces adlins[] when CMF file std::vector<adldata> dynamic_instruments; // Replaces adl[] when CMF file const unsigned DynamicInstrumentTag /* = 0x8000u*/, diff --git a/src/midiplay/adlmidiplay.cpp b/src/midiplay/adlmidiplay.cpp index ca22025..0cefb7c 100644 --- a/src/midiplay/adlmidiplay.cpp +++ b/src/midiplay/adlmidiplay.cpp @@ -199,6 +199,7 @@ int main(int argc, char **argv) std::fprintf(stderr, "%s\n", adl_errorString()); return 0; } + std::fprintf(stdout, "Number of cards %s\n", argv[3]); } if(argc >= 5) { @@ -207,6 +208,7 @@ int main(int argc, char **argv) std::fprintf(stderr, "%s\n", adl_errorString()); return 0; } + std::fprintf(stdout, "Number of four-ops %s\n", argv[4]); } if(adl_openFile(myDevice, argv[1]) != 0) |