aboutsummaryrefslogtreecommitdiff
path: root/src/adlmidi_midiplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/adlmidi_midiplay.cpp')
-rw-r--r--src/adlmidi_midiplay.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index b300270..9841f73 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -397,13 +397,27 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity)
if((m_synth.m_rhythmMode == 1) && PercussionMap[midiins & 0xFF])
voices[1] = voices[0];//i[1] = i[0];
+ bool isBlankNote = (ains->flags & adlinsdata::Flag_NoSound);
+
if(hooks.onDebugMessage)
{
- if((ains->flags & adlinsdata::Flag_NoSound) &&
- caugh_missing_instruments.insert(static_cast<uint8_t>(midiins)).second)
+ if(isBlankNote && caugh_missing_instruments.insert(static_cast<uint8_t>(midiins)).second)
hooks.onDebugMessage(hooks.onDebugMessage_userData, "[%i] Playing missing instrument %i", channel, midiins);
}
+ if(isBlankNote)
+ {
+ // Don't even try to play the blank instrument! But, insert the dummy note.
+ std::pair<MIDIchannel::activenoteiterator, bool>
+ dummy = midiChan.activenotes_insert(note);
+ dummy.first->isBlank = true;
+ dummy.first->ains = NULL;
+ dummy.first->chip_channels_count = 0;
+ // Record the last note on MIDI channel as source of portamento
+ midiChan.portamentoSource = static_cast<int8_t>(note);
+ return false;
+ }
+
// Allocate AdLib channel (the physical sound channel for the note)
int32_t adlchannel[MIDIchannel::NoteInfo::MaxNumPhysChans] = { -1, -1 };
@@ -499,6 +513,8 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity)
ir.first->currentTone = tone;
ir.first->glideRate = HUGE_VAL;
ir.first->midiins = midiins;
+ ir.first->isPercussion = isPercussion;
+ ir.first->isBlank = isBlankNote;
ir.first->ains = ains;
ir.first->chip_channels_count = 0;
@@ -1044,6 +1060,13 @@ void MIDIplay::noteUpdate(size_t midCh,
my_loc.MidCh = static_cast<uint16_t>(midCh);
my_loc.note = info.note;
+ if(info.isBlank)
+ {
+ if(props_mask & Upd_Off)
+ m_midiChannels[midCh].activenotes_erase(i);
+ return;
+ }
+
for(unsigned ccount = 0, ctotal = info.chip_channels_count; ccount < ctotal; ccount++)
{
const MIDIchannel::NoteInfo::Phys &ins = info.chip_channels[ccount];
@@ -1295,7 +1318,7 @@ int64_t MIDIplay::calculateChipChannelGoodness(size_t c, const MIDIchannel::Note
}
// Percussion is inferior to melody
- s += 50 * (int64_t)(k->midiins / 128);
+ s += k->isPercussion ? 50 : 0;
/*
if(k->second.midiins >= 25
&& k->second.midiins < 40