diff options
author | Wohlstand <admin@wohlnet.ru> | 2016-12-09 19:15:39 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2016-12-09 19:15:39 +0300 |
commit | 28a253742adfb1ac6199b0f068701f071db6299b (patch) | |
tree | 2416032bd117123cce143d1705fb88ebef295f54 | |
parent | 6793da0556d1821b2d8d79886ab67a7598e30f35 (diff) | |
download | libADLMIDI-28a253742adfb1ac6199b0f068701f071db6299b.tar.gz libADLMIDI-28a253742adfb1ac6199b0f068701f071db6299b.tar.bz2 libADLMIDI-28a253742adfb1ac6199b0f068701f071db6299b.zip |
Added a changalbe volume ranges model
(to allow banks play sound be more native like to their original implementations)
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | src/adlmidi.cpp | 84 | ||||
-rw-r--r-- | src/adlmidi.h | 15 |
3 files changed, 94 insertions, 8 deletions
@@ -74,6 +74,9 @@ To build that example you will need to have installed SDL2 library. to play any MIDI via this library. # Changelog +## 1.1.1 2016-12-09 + * Added a changable volume ranges models (Automatic for some banks, Generic, CMF, DMX, Apogee and 9X) + ## 1.1.0 2016-12-06 * Added Nuked OPL3 emulator which is more accurate (but requires more CPU power, therefore kept ability to use DosBox OPL3 via macro) * Fixed warnings of CLang code model plugin diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp index 5f7aeca..67cd853 100644 --- a/src/adlmidi.cpp +++ b/src/adlmidi.cpp @@ -486,6 +486,37 @@ struct OPL3 } } } + + void ChangeVolumeRangesModel(ADLMIDI_VolumeModels volumeModel) + { + switch(volumeModel) + { + case ADLMIDI_VolumeModel_AUTO://Do nothing until restart playing + break; + + case ADLMIDI_VolumeModel_Generic: + m_volumeScale = OPL3::VOLUME_Generic; + break; + + case ADLMIDI_VolumeModel_CMF: + LogarithmicVolumes = true; + m_volumeScale = OPL3::VOLUME_CMF; + break; + + case ADLMIDI_VolumeModel_DMX: + m_volumeScale = OPL3::VOLUME_DMX; + break; + + case ADLMIDI_VolumeModel_APOGEE: + m_volumeScale = OPL3::VOLUME_APOGEE; + break; + + case ADLMIDI_VolumeModel_9X: + m_volumeScale = OPL3::VOLUME_9X; + break; + } + } + void Reset() { LogarithmicVolumes = false; @@ -1072,12 +1103,39 @@ riffskip: opl.HighVibratoMode = config->HighVibratoMode; opl.ScaleModulators = config->ScaleModulators; opl.LogarithmicVolumes = config->LogarithmicVolumes; - /* ====== EXPERIMENTALLY - Add function to switch this!!! ========*/ - opl.m_volumeScale = config->AdlBank == 14 ? OPL3::VOLUME_DMX : - config->AdlBank == 62 ? OPL3::VOLUME_APOGEE : - config->AdlBank == 58 ? OPL3::VOLUME_9X : - OPL3::VOLUME_Generic; - /* ===============================================================*/ + opl.ChangeVolumeRangesModel(static_cast<ADLMIDI_VolumeModels>(config->VolumeModel)); + + if(config->VolumeModel == ADLMIDI_VolumeModel_AUTO) + { + switch(config->AdlBank) + { + default: + opl.m_volumeScale = OPL3::VOLUME_Generic; + break; + + case 14://Doom 2 + case 15://Heretic + case 16://Doom 1 + case 64://Raptor + opl.m_volumeScale = OPL3::VOLUME_DMX; + break; + + case 58://FatMan bank hardcoded in the Windows 9x drivers + case 65://Modded Wohlstand's Fatman bank + case 66://O'Connel's bank + opl.m_volumeScale = OPL3::VOLUME_9X; + break; + + case 62://Duke Nukem 3D + case 63://Shadow Warrior + case 69://Blood + case 70://Lee + case 71://Nam + opl.m_volumeScale = OPL3::VOLUME_APOGEE; + break; + } + } + opl.NumCards = config->NumCards; opl.NumFourOps = config->NumFourOps; cmf_percussion_mode = false; @@ -2524,9 +2582,11 @@ retry_arpeggio: AdlChannel::users_t::const_iterator i = ch[c].users.begin(); size_t rate_reduction = 3; - if(n_users >= 3) rate_reduction = 2; + if(n_users >= 3) + rate_reduction = 2; - if(n_users >= 4) rate_reduction = 1; + if(n_users >= 4) + rate_reduction = 1; std::advance(i, (arpeggio_counter / rate_reduction) % n_users); @@ -2796,6 +2856,14 @@ ADLMIDI_EXPORT void adl_setLogarithmicVolumes(struct ADL_MIDIPlayer *device, int reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.LogarithmicVolumes = (bool)device->LogarithmicVolumes; } +ADLMIDI_EXPORT void adl_setVolumeRangeModel(ADL_MIDIPlayer *device, int volumeModel) +{ + if(!device) return; + + device->VolumeModel = volumeModel; + reinterpret_cast<MIDIplay *>(device->adl_midiPlayer)->opl.ChangeVolumeRangesModel(static_cast<ADLMIDI_VolumeModels>(volumeModel)); +} + ADLMIDI_EXPORT int adl_openFile(ADL_MIDIPlayer *device, char *filePath) { ADLMIDI_ErrorString.clear(); diff --git a/src/adlmidi.h b/src/adlmidi.h index e945f29..9c09028 100644 --- a/src/adlmidi.h +++ b/src/adlmidi.h @@ -28,6 +28,16 @@ extern "C" { #endif +enum ADLMIDI_VolumeModels +{ + ADLMIDI_VolumeModel_AUTO = 0, + ADLMIDI_VolumeModel_Generic, + ADLMIDI_VolumeModel_CMF, + ADLMIDI_VolumeModel_DMX, + ADLMIDI_VolumeModel_APOGEE, + ADLMIDI_VolumeModel_9X +}; + struct ADL_MIDIPlayer { unsigned int AdlBank; @@ -37,6 +47,7 @@ struct ADL_MIDIPlayer unsigned int HighVibratoMode; unsigned int AdlPercussionMode; unsigned int LogarithmicVolumes; + int VolumeModel; unsigned int QuitFlag; unsigned int SkipForward; unsigned int QuitWithoutLooping; @@ -92,6 +103,10 @@ extern void adl_setLoopEnabled(struct ADL_MIDIPlayer *device, int loopEn); /*Enable or disable Logariphmic volume changer */ extern void adl_setLogarithmicVolumes(struct ADL_MIDIPlayer *device, int logvol); +/*Set different volume range model */ +extern void adl_setVolumeRangeModel(struct ADL_MIDIPlayer *device, int volumeModel); + + /*Returns string which contains last error message*/ extern const char *adl_errorString(); |