From a60dc64e717cd8399aec9191c6e60afd5c5c4840 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 25 Mar 2018 01:37:44 +0300 Subject: [PATCH] ADL&OPN: Fix `long` vs `int64` conflict in 'CalcChGoodness' --- src/sound/adlmidi/adlmidi_midiplay.cpp | 12 ++++++------ src/sound/adlmidi/adlmidi_private.hpp | 2 +- src/sound/opnmidi/opnmidi_midiplay.cpp | 10 +++++----- src/sound/opnmidi/opnmidi_private.hpp | 3 +-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/sound/adlmidi/adlmidi_midiplay.cpp b/src/sound/adlmidi/adlmidi_midiplay.cpp index ea3b1fefb6..65e7af5efe 100644 --- a/src/sound/adlmidi/adlmidi_midiplay.cpp +++ b/src/sound/adlmidi/adlmidi_midiplay.cpp @@ -2109,9 +2109,9 @@ void MIDIplay::HandleEvent(size_t tk, const MIDIplay::MidiEvent &evt, int &statu } #endif -long MIDIplay::CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteInfo::Phys &ins, uint16_t) const +int64_t MIDIplay::CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteInfo::Phys &ins, uint16_t) const { - long s = -ch[c].koff_time_until_neglible; + int64_t s = -ch[c].koff_time_until_neglible; // Same midi-instrument = some stability //if(c == MidCh) s += 4; @@ -2123,9 +2123,9 @@ long MIDIplay::CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteIn s -= 4000; if(!j->second.sustained) - s -= (long)j->second.kon_time_until_neglible; + s -= j->second.kon_time_until_neglible; else - s -= (long)(j->second.kon_time_until_neglible / 2); + s -= (j->second.kon_time_until_neglible / 2); MIDIchannel::activenotemap_t::const_iterator k = Ch[j->first.MidCh].activenotes.find(j->first.note); @@ -2143,7 +2143,7 @@ long MIDIplay::CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteIn } // Percussion is inferior to melody - s += 50 * (k->second.midiins / 128); + s += 50 * (int64_t)(k->second.midiins / 128); /* if(k->second.midiins >= 25 && k->second.midiins < 40 @@ -2178,7 +2178,7 @@ long MIDIplay::CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteIn } } - s += n_evacuation_stations * 4; + s += (int64_t)n_evacuation_stations * 4; } return s; diff --git a/src/sound/adlmidi/adlmidi_private.hpp b/src/sound/adlmidi/adlmidi_private.hpp index 8f0c6579fa..852334328b 100644 --- a/src/sound/adlmidi/adlmidi_private.hpp +++ b/src/sound/adlmidi/adlmidi_private.hpp @@ -965,7 +965,7 @@ private: // Determine how good a candidate this adlchannel // would be for playing a note from this instrument. - long CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteInfo::Phys &ins, uint16_t /*MidCh*/) const; + int64_t CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteInfo::Phys &ins, uint16_t /*MidCh*/) const; // A new note will be played on this channel using this instrument. // Kill existing notes on this channel (or don't, if we do arpeggio) diff --git a/src/sound/opnmidi/opnmidi_midiplay.cpp b/src/sound/opnmidi/opnmidi_midiplay.cpp index 50bc21742f..630df1c77a 100644 --- a/src/sound/opnmidi/opnmidi_midiplay.cpp +++ b/src/sound/opnmidi/opnmidi_midiplay.cpp @@ -2031,9 +2031,9 @@ void OPNMIDIplay::HandleEvent(size_t tk, const OPNMIDIplay::MidiEvent &evt, int } #endif //OPNMIDI_DISABLE_MIDI_SEQUENCER -long OPNMIDIplay::CalculateAdlChannelGoodness(size_t c, uint16_t ins, uint16_t) const +int64_t OPNMIDIplay::CalculateAdlChannelGoodness(size_t c, uint16_t ins, uint16_t) const { - long s = -ch[c].koff_time_until_neglible; + int64_t s = -ch[c].koff_time_until_neglible; // Same midi-instrument = some stability //if(c == MidCh) s += 4; @@ -2045,9 +2045,9 @@ long OPNMIDIplay::CalculateAdlChannelGoodness(size_t c, uint16_t ins, uint16_t) s -= 4000; if(!j->second.sustained) - s -= (long)j->second.kon_time_until_neglible; + s -= j->second.kon_time_until_neglible; else - s -= (long)(j->second.kon_time_until_neglible / 2); + s -= (j->second.kon_time_until_neglible / 2); MIDIchannel::activenotemap_t::const_iterator k = Ch[j->first.MidCh].activenotes.find(j->first.note); @@ -2065,7 +2065,7 @@ long OPNMIDIplay::CalculateAdlChannelGoodness(size_t c, uint16_t ins, uint16_t) } // Percussion is inferior to melody - s += 50 * (k->second.midiins / 128); + s += 50 * (int64_t)(k->second.midiins / 128); /* if(k->second.midiins >= 25 && k->second.midiins < 40 diff --git a/src/sound/opnmidi/opnmidi_private.hpp b/src/sound/opnmidi/opnmidi_private.hpp index 4654456aa2..10cda97167 100644 --- a/src/sound/opnmidi/opnmidi_private.hpp +++ b/src/sound/opnmidi/opnmidi_private.hpp @@ -94,7 +94,6 @@ typedef __int32 ssize_t; #include "opnbank.h" #include "opnmidi.h" - #define ADL_UNUSED(x) (void)x extern std::string OPN2MIDI_ErrorString; @@ -894,7 +893,7 @@ private: // Determine how good a candidate this adlchannel // would be for playing a note from this instrument. - long CalculateAdlChannelGoodness(size_t c, uint16_t ins, uint16_t /*MidCh*/) const; + int64_t CalculateAdlChannelGoodness(size_t c, uint16_t ins, uint16_t /*MidCh*/) const; // A new note will be played on this channel using this instrument. // Kill existing notes on this channel (or don't, if we do arpeggio)