aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVitaly Novichkov <admin@wohlnet.ru>2018-09-30 18:58:13 +0300
committerVitaly Novichkov <admin@wohlnet.ru>2018-09-30 18:58:13 +0300
commit77e8b86be524edf42a7070e2b7a1f6f67d7cfaa8 (patch)
tree82e77298d966a3295c88479ac3ae1abc5a1f84f8 /src
parent10c6c335697cd7e570d06089c61c1fae8acb29e1 (diff)
downloadlibADLMIDI-77e8b86be524edf42a7070e2b7a1f6f67d7cfaa8.tar.gz
libADLMIDI-77e8b86be524edf42a7070e2b7a1f6f67d7cfaa8.tar.bz2
libADLMIDI-77e8b86be524edf42a7070e2b7a1f6f67d7cfaa8.zip
Move "MaxChips" constant macro into adlmidi_private.hpp
Diffstat (limited to 'src')
-rw-r--r--src/adlmidi.cpp12
-rw-r--r--src/adlmidi_midiplay.cpp4
-rw-r--r--src/adlmidi_private.hpp8
3 files changed, 14 insertions, 10 deletions
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index d0aa85f..12d0e68 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -23,14 +23,6 @@
#include "adlmidi_private.hpp"
-#ifdef ADLMIDI_HW_OPL
-#define MaxChips 1
-#define MaxChips_STR "1" //Why not just "#MaxCards" ? Watcom fails to pass this with "syntax error" :-P
-#else
-#define MaxChips 100
-#define MaxChips_STR "100"
-#endif
-
/* Unify MIDI player casting and interface between ADLMIDI and OPNMIDI */
#define GET_MIDI_PLAYER(device) reinterpret_cast<MIDIplay *>((device)->adl_midiPlayer)
typedef MIDIplay MidiPlayer;
@@ -107,9 +99,9 @@ ADLMIDI_EXPORT int adl_setNumChips(ADL_MIDIPlayer *device, int numChips)
#else
play->m_setup.numChips = static_cast<unsigned int>(numChips);
#endif
- if(play->m_setup.numChips < 1 || play->m_setup.numChips > MaxChips)
+ if(play->m_setup.numChips < 1 || play->m_setup.numChips > ADL_MAX_CHIPS)
{
- play->setErrorString("number of chips may only be 1.." MaxChips_STR ".\n");
+ play->setErrorString("number of chips may only be 1.." ADL_MAX_CHIPS_STR ".\n");
return -1;
}
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index 673ec30..1e1da07 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -1465,6 +1465,8 @@ void MIDIplay::killOrEvacuate(size_t from_channel,
AdlChannel::LocationData *j,
MIDIplay::MIDIchannel::activenoteiterator i)
{
+ uint32_t maxChannels = ADL_MAX_CHIPS * 18;
+
// Before killing the note, check if it can be
// evacuated to another channel as an arpeggio
// instrument. This helps if e.g. all channels
@@ -1474,6 +1476,8 @@ void MIDIplay::killOrEvacuate(size_t from_channel,
{
uint16_t cs = static_cast<uint16_t>(c);
+ if(c >= maxChannels)
+ break;
if(c == from_channel)
continue;
if(m_synth.m_channelCategory[c] != m_synth.m_channelCategory[from_channel])
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index c3d65c0..59ba555 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -161,6 +161,14 @@ typedef BW_MidiSequencer MidiSequencer;
#define OPL_PANNING_RIGHT 0x20
#define OPL_PANNING_BOTH 0x30
+#ifdef ADLMIDI_HW_OPL
+#define ADL_MAX_CHIPS 1
+#define ADL_MAX_CHIPS_STR "1" //Why not just "#MaxCards" ? Watcom fails to pass this with "syntax error" :-P
+#else
+#define ADL_MAX_CHIPS 100
+#define ADL_MAX_CHIPS_STR "100"
+#endif
+
extern std::string ADLMIDI_ErrorString;
/*