aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2017-11-05 21:01:37 +0300
committerWohlstand <admin@wohlnet.ru>2017-11-05 21:01:37 +0300
commit3bcaac365e914b82f80839e047ebedd6b81fc634 (patch)
tree61105b57fac1fed72f5562ee47f7829bb0af1fb0
parent44b9892c91476fe4e64b67f3868322b097003335 (diff)
downloadlibADLMIDI-3bcaac365e914b82f80839e047ebedd6b81fc634.tar.gz
libADLMIDI-3bcaac365e914b82f80839e047ebedd6b81fc634.tar.bz2
libADLMIDI-3bcaac365e914b82f80839e047ebedd6b81fc634.zip
Tri-state for deep-tremolo/vibrato/sm/adlib-percussion modes
By default every flag will have "auto" type which means mode will be set in dependence on a bank.
-rw-r--r--README.md1
-rw-r--r--include/adlmidi.h8
-rw-r--r--src/adlmidi.cpp6
-rw-r--r--src/adlmidi_load.cpp15
-rw-r--r--src/adlmidi_midiplay.cpp22
-rw-r--r--src/adlmidi_private.hpp12
6 files changed, 29 insertions, 35 deletions
diff --git a/README.md b/README.md
index 487b965..37599d5 100644
--- a/README.md
+++ b/README.md
@@ -133,6 +133,7 @@ To build that example you will need to have installed SDL2 library.
* Added hooks to increase advandate of The Library: MIDI-event, Note, and Debug-Message hooks!
* Fixed the ability to merge two equal pseudo-4-operator voices as one voice without damaging the result!
* Added auto-increasing of percussion note lengths when there are too short and playing an incorrect sound on various banks
+ * Tri-state support for deep-tremolo/vibrato, scale modulators, and legacy adlib percussion mode. -1 means "auto", I.e. default and specified by bank.
* ...
## 1.2.1 2017-07-30
diff --git a/include/adlmidi.h b/include/adlmidi.h
index 2c3abf4..6ecb22b 100644
--- a/include/adlmidi.h
+++ b/include/adlmidi.h
@@ -73,16 +73,16 @@ extern const char *const *adl_getBankNames();
/*Sets number of 4-chan operators*/
extern int adl_setNumFourOpsChn(struct ADL_MIDIPlayer *device, int ops4);
-/*Enable or disable AdLib percussion mode*/
+/*Override Enable(1) or Disable(0) AdLib percussion mode. -1 - use bank default AdLib percussion mode*/
extern void adl_setPercMode(struct ADL_MIDIPlayer *device, int percmod);
-/*Enable or disable deep vibrato*/
+/*Override Enable(1) or Disable(0) deep vibrato state. -1 - use bank default vibrato state*/
extern void adl_setHVibrato(struct ADL_MIDIPlayer *device, int hvibro);
-/*Enable or disable deep tremolo*/
+/*Override Enable(1) or Disable(0) deep tremolo state. -1 - use bank default tremolo state*/
extern void adl_setHTremolo(struct ADL_MIDIPlayer *device, int htremo);
-/*Enable or disable Enables scaling of modulator volumes*/
+/*Override Enable(1) or Disable(0) scaling of modulator volumes. -1 - use bank default scaling of modulator volumes*/
extern void adl_setScaleModulators(struct ADL_MIDIPlayer *device, int smod);
/*Enable or disable built-in loop (built-in loop supports 'loopStart' and 'loopEnd' tags to loop specific part)*/
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index 8f07d72..9a0aaa4 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -525,9 +525,9 @@ ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out)
n_periodCountStereo = static_cast<ssize_t>(setup.carry);
setup.carry -= n_periodCountStereo;
- if(setup.SkipForward > 0)
- setup.SkipForward -= 1;
- else
+ //if(setup.SkipForward > 0)
+ // setup.SkipForward -= 1;
+ //else
{
if((player->atEnd) && (setup.delay <= 0.0))
break;//Stop to fetch samples at reaching the song end with disabled loop
diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp
index 387ca12..6f68a11 100644
--- a/src/adlmidi_load.cpp
+++ b/src/adlmidi_load.cpp
@@ -361,19 +361,12 @@ bool MIDIplay::LoadMIDI(MIDIplay::fileReader &fr)
}
/**** Set all properties BEFORE starting of actial file reading! ****/
-
m_setup.stored_samples = 0;
m_setup.backup_samples_size = 0;
-
- /*
- * TODO: Implement tri-state: "AUTO (use bank default setup), force On, force Off"
- * for thuse four flags:
- */
- opl.HighTremoloMode = m_setup.HighTremoloMode;
- opl.HighVibratoMode = m_setup.HighVibratoMode;
- opl.AdlPercussionMode = m_setup.AdlPercussionMode;
- opl.ScaleModulators = m_setup.ScaleModulators;
-
+ opl.HighTremoloMode = m_setup.HighTremoloMode == -1 ? adlbanksetup[m_setup.AdlBank].deepTremolo : (bool)m_setup.HighTremoloMode;
+ opl.HighVibratoMode = m_setup.HighVibratoMode == -1 ? adlbanksetup[m_setup.AdlBank].deepVibrato : (bool)m_setup.HighVibratoMode;
+ opl.AdlPercussionMode = m_setup.AdlPercussionMode == -1 ? adlbanksetup[m_setup.AdlBank].adLibPercussions : (bool)m_setup.AdlPercussionMode;
+ opl.ScaleModulators = m_setup.ScaleModulators == -1 ? adlbanksetup[m_setup.AdlBank].scaleModulators : (bool)m_setup.ScaleModulators;
opl.LogarithmicVolumes = m_setup.LogarithmicVolumes;
//opl.CartoonersVolumes = false;
opl.m_musicMode = OPL3::MODE_MIDI;
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index 27ec8d4..fa95e32 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -639,13 +639,13 @@ MIDIplay::MIDIplay():
m_setup.AdlBank = 0;
m_setup.NumFourOps = 7;
m_setup.NumCards = 2;
- m_setup.HighTremoloMode = false;
- m_setup.HighVibratoMode = false;
- m_setup.AdlPercussionMode = false;
- m_setup.LogarithmicVolumes = false;
- m_setup.SkipForward = 0;
+ m_setup.HighTremoloMode = -1;
+ m_setup.HighVibratoMode = -1;
+ m_setup.AdlPercussionMode = -1;
+ m_setup.LogarithmicVolumes = false;
+ //m_setup.SkipForward = 0;
m_setup.loopingIsEnabled = false;
- m_setup.ScaleModulators = false;
+ m_setup.ScaleModulators = -1;
m_setup.delay = 0.0;
m_setup.carry = 0.0;
m_setup.stored_samples = 0;
@@ -654,11 +654,11 @@ MIDIplay::MIDIplay():
opl.NumCards = m_setup.NumCards;
opl.AdlBank = m_setup.AdlBank;
opl.NumFourOps = m_setup.NumFourOps;
- opl.LogarithmicVolumes = m_setup.LogarithmicVolumes;
- opl.HighTremoloMode = m_setup.HighTremoloMode;
- opl.HighVibratoMode = m_setup.HighVibratoMode;
- opl.AdlPercussionMode = m_setup.AdlPercussionMode;
- opl.ScaleModulators = m_setup.ScaleModulators;
+ opl.LogarithmicVolumes = m_setup.LogarithmicVolumes;
+ opl.HighTremoloMode = m_setup.HighTremoloMode == -1 ? adlbanksetup[m_setup.AdlBank].deepTremolo : (bool)m_setup.HighTremoloMode;
+ opl.HighVibratoMode = m_setup.HighVibratoMode == -1 ? adlbanksetup[m_setup.AdlBank].deepVibrato : (bool)m_setup.HighVibratoMode;
+ opl.AdlPercussionMode = m_setup.AdlPercussionMode == -1 ? adlbanksetup[m_setup.AdlBank].adLibPercussions : (bool)m_setup.AdlPercussionMode;
+ opl.ScaleModulators = m_setup.ScaleModulators == -1 ? adlbanksetup[m_setup.AdlBank].scaleModulators : (bool)m_setup.ScaleModulators;
}
uint64_t MIDIplay::ReadVarLen(uint8_t **ptr)
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index a0f2a51..42e24e2 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -629,14 +629,14 @@ public:
unsigned int AdlBank;
unsigned int NumFourOps;
unsigned int NumCards;
- bool HighTremoloMode;
- bool HighVibratoMode;
- bool AdlPercussionMode;
+ int HighTremoloMode;
+ int HighVibratoMode;
+ int AdlPercussionMode;
bool LogarithmicVolumes;
int VolumeModel;
- unsigned int SkipForward;
- bool loopingIsEnabled;
- bool ScaleModulators;
+ //unsigned int SkipForward;
+ bool loopingIsEnabled;
+ int ScaleModulators;
double delay;
double carry;