aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--include/adlmidi.h6
-rw-r--r--src/adlmidi.cpp7
-rw-r--r--src/adlmidi_midiplay.cpp10
-rw-r--r--src/adlmidi_private.hpp1
5 files changed, 25 insertions, 0 deletions
diff --git a/README.md b/README.md
index 4ab9256..b7a65bf 100644
--- a/README.md
+++ b/README.md
@@ -139,6 +139,7 @@ To build that example you will need to have installed SDL2 library.
* Fixed blank instruments fallback in multi-bank support. When using non-zero bank, if instrument is blank, then, instrument will be taken from a root (I.e. zero bank).
* Added support for real-time switching the emulator
* Added support for CC-120 - "All sound off" on the MIDI channel
+ * Changed logic of CC-74 Brightness to affect sound only between 0 and 64 like real XG synthesizers. Ability to turn on a full-ranged brightness (to use full 0...127 range) is kept.
## 1.3.1 2017-12-16
* Added Real-Time MIDI API (MIDI event functions and adl_generate() to generate PCM between of event rows) which allows you to implement plugin for media players or even a real time MIDI playing driver.
diff --git a/include/adlmidi.h b/include/adlmidi.h
index 6786f4a..b21df2c 100644
--- a/include/adlmidi.h
+++ b/include/adlmidi.h
@@ -110,6 +110,12 @@ extern void adl_setHTremolo(struct ADL_MIDIPlayer *device, int htremo);
/*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(1) or Disable(0) full-range brightness (MIDI CC74 used in XG music to filter result sounding) scaling.
+ By default, brightness affects sound between 0 and 64.
+ When this option is enabled, the range will use a full range from 0 up to 127.
+*/
+extern void adl_setFullRangeBrightness(struct ADL_MIDIPlayer *device, int fr_brightness);
+
/*Enable or disable built-in loop (built-in loop supports 'loopStart' and 'loopEnd' tags to loop specific part)*/
extern void adl_setLoopEnabled(struct ADL_MIDIPlayer *device, int loopEn);
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index 4744903..df00706 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -200,6 +200,13 @@ ADLMIDI_EXPORT void adl_setScaleModulators(ADL_MIDIPlayer *device, int smod)
play->opl.ScaleModulators = play->m_setup.ScaleModulators;
}
+ADLMIDI_EXPORT void adl_setFullRangeBrightness(struct ADL_MIDIPlayer *device, int fr_brightness)
+{
+ if(!device) return;
+ MIDIplay *play = reinterpret_cast<MIDIplay *>(device->adl_midiPlayer);
+ play->m_setup.fullRangeBrightnessCC74 = fr_brightness;
+}
+
ADLMIDI_EXPORT void adl_setLoopEnabled(ADL_MIDIPlayer *device, int loopEn)
{
if(!device) return;
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index 901e6ea..7911adc 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -727,6 +727,7 @@ MIDIplay::MIDIplay(unsigned long sampleRate):
//m_setup.SkipForward = 0;
m_setup.loopingIsEnabled = false;
m_setup.ScaleModulators = -1;
+ m_setup.fullRangeBrightnessCC74 = false;
m_setup.delay = 0.0;
m_setup.carry = 0.0;
m_setup.tick_skip_samples_delay = 0;
@@ -1544,6 +1545,15 @@ void MIDIplay::NoteUpdate(uint16_t MidCh,
bool is_percussion = (MidCh == 9) || Ch[MidCh].is_xg_percussion;
uint8_t brightness = is_percussion ? 127 : Ch[MidCh].brightness;
+ if(!m_setup.fullRangeBrightnessCC74)
+ {
+ // Simulate post-High-Pass filter result which affects sounding by half level only
+ if(brightness >= 64)
+ brightness = 127;
+ else
+ brightness *= 2;
+ }
+
switch(opl.m_volumeScale)
{
case OPL3::VOLUME_Generic:
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index 312f462..8e5f060 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -792,6 +792,7 @@ public:
//unsigned int SkipForward;
bool loopingIsEnabled;
int ScaleModulators;
+ bool fullRangeBrightnessCC74;
double delay;
double carry;