aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--src/adlmidi.cpp84
-rw-r--r--src/adlmidi.h15
3 files changed, 94 insertions, 8 deletions
diff --git a/README.md b/README.md
index e71b870..6e258a7 100644
--- a/README.md
+++ b/README.md
@@ -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();