diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannel.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannel.hpp index 4759ea86..9139c553 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannel.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannel.hpp @@ -15,28 +15,13 @@ namespace HyperSonicDrivers::drivers::midi explicit IMidiChannel(const uint8_t channel); virtual ~IMidiChannel() = default; - const uint8_t channel; // MIDI channel, not used + const uint8_t channel; // MIDI channel number uint8_t volume = 0; // channel volume - uint8_t pan = 0; // pan, 0=normal - uint16_t pitch = 0; // pitch wheel, 0=normal + uint8_t pan = 64; // pan, 64=center + uint16_t pitch = 0; // pitch wheel, 0=normal uint8_t sustain = 0; // sustain pedal value uint8_t modulation = 0; // modulation pot value uint8_t program = 0; // instrument number const bool isPercussion; - - protected: - //std::list m_voices; - // MIDI Events - //virtual void noteOff(const uint8_t note) noexcept = 0; - //virtual void noteOn(const uint8_t note, const uint8_t vol) noexcept = 0; - //virtual void controller(const uint8_t ctrl, uint8_t value) noexcept = 0; - //virtual void programChange(const uint8_t program) noexcept = 0; - //virtual void pitchBend(const uint16_t bend) noexcept = 0; - - // MIDI Controller Events - //virtual void ctrl_modulationWheel(const uint8_t value) const noexcept = 0; - //virtual void ctrl_volume(const uint8_t value) const noexcept = 0; - //virtual void ctrl_panPosition(uint8_t value) const noexcept = 0; - //virtual void ctrl_sustain(uint8_t value) const noexcept = 0; }; } diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannelVoice.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannelVoice.hpp index 79a8706d..23c0d7c3 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannelVoice.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannelVoice.hpp @@ -19,9 +19,10 @@ namespace HyperSonicDrivers::drivers::midi inline IMidiChannel* getChannel() const noexcept { return m_channel; } uint8_t getChannelNum() const noexcept; inline uint8_t getNote() const noexcept { return m_note; } - inline uint8_t getVolume() const noexcept { return m_volume; }; + //inline uint8_t getVolume() const noexcept { return m_volume; }; void setVolumes(const uint8_t volume) noexcept; inline bool isFree() const noexcept { return m_free; } + inline bool isSustain() const noexcept { return m_sustain; }; inline bool isVibrato() const noexcept { return m_vibrato; } protected: diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/opl/OplDriver.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/opl/OplDriver.cpp index e0fe5bdc..c851df30 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/opl/OplDriver.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/opl/OplDriver.cpp @@ -11,9 +11,6 @@ namespace HyperSonicDrivers::drivers::midi::opl using hardware::opl::opl2_num_channels; using hardware::opl::opl3_num_channels; - //using audio::midi::MIDI_EVENT_TYPES_HIGH; - //using audio::midi::TO_HIGH; - //using hardware::opl::OPL2instrument_t; using hardware::opl::OplType; using utils::logW; using utils::logE; @@ -95,40 +92,6 @@ namespace HyperSonicDrivers::drivers::midi::opl // but the same logic of the thread will be performed here. } - /*void OplDriver::send(const audio::midi::MIDIEvent& e) noexcept - { - switch (TO_HIGH(e.type.high)) - { - case MIDI_EVENT_TYPES_HIGH::NOTE_OFF: - noteOff(e.type.low, e.data[0]); - break; - case MIDI_EVENT_TYPES_HIGH::NOTE_ON: - noteOn(e.type.low, e.data[0], e.data[1]); - break; - case MIDI_EVENT_TYPES_HIGH::AFTERTOUCH: - logW("AFTERTOUCH not supported"); - break; - case MIDI_EVENT_TYPES_HIGH::CONTROLLER: - controller(e.type.low, e.data[0], e.data[1]); - break; - case MIDI_EVENT_TYPES_HIGH::PROGRAM_CHANGE: - programChange(e.type.low, e.data[0]); - break; - case MIDI_EVENT_TYPES_HIGH::CHANNEL_AFTERTOUCH: - logW("CHANNEL_AFTERTOUCH not supported"); - break; - case MIDI_EVENT_TYPES_HIGH::PITCH_BEND: - pitchBend(e.type.low, static_cast((e.data[0] | (e.data[1] << 7) - 0x2000) >> 6)); - break; - case MIDI_EVENT_TYPES_HIGH::META_SYSEX: - logW("META_SYSEX not supported"); - break; - default: - logW(std::format("OplDriver: Unknown send() command {:#0x}", e.type.val)); - break; - } - }*/ - void OplDriver::pause() const noexcept { for (auto it = m_voicesInUseIndex.begin(); it != m_voicesInUseIndex.end(); ++it) { @@ -194,84 +157,6 @@ namespace HyperSonicDrivers::drivers::midi::opl } } - //void OplDriver::controller(const uint8_t chan, const uint8_t control, uint8_t value) noexcept - //{ - // // MIDI_EVENT_CONTROLLER_TYPES - // switch (control) - // { - // case 0: - // case 32: - // // Bank select. Not supported - // logW(std::format("bank select value {}", value)); - // break; - // case 1: - // ctrl_modulationWheel(chan, value); - // //spdlog::debug("modwheel value {}", value); - // break; - // case 7: - // ctrl_volume(chan, value); - // break; - // case 10: - // // Not Available on OPL2/AdLib. - // - // ctrl_panPosition(chan, value); - // break; - // case 16: - // //pitchBendFactor(value); - // logW(std::format("pitchBendFactor value {}", value)); - // break; - // case 17: - // //detune(value); - // logW(std::format("detune value {}", value)); - // break; - // case 18: - // //priority(value); - // logW(std::format("priority value {}", value)); - // break; - // case 64: - // ctrl_sustain(chan, value); - // break; - // case 91: - // // Effects level. Not supported. - // //effectLevel(value); - // logW(std::format("effect level value {}", value)); - // break; - // case 93: - // // Chorus level. Not supported. - // //chorusLevel(value); - // logW(std::format("chorus level value {}", value)); - // break; - // case 119: - // // Unknown, used in Simon the Sorcerer 2 - // logW(std::format("unknown value {}", value)); - // break; - // case 121: - // // reset all controllers - // logW("reset all controllers value"); - // //modulationWheel(0); - // //pitchBendFactor(0); - // //detune(0); - // //sustain(false); - // break; - // case 123: - // //spdlog::debug("all notes off"); - // m_oplWriter->stopAll(); - // break; - // default: - // logW(std::format("OplDriver: Unknown control change message {:d} {:d}", control, value)); - // } - //} - - /*void OplDriver::programChange(const uint8_t chan, const uint8_t program) noexcept - { - if (program > 127) - { - logW(std::format("Progam change value >= 127 -> {}", program)); - } - - m_channels[chan]->program = program; - }*/ - void OplDriver::pitchBend(const uint8_t chan, const uint16_t bend) noexcept { m_channels[chan]->pitch = bend; diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdlibVoice.h b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdlibVoice.h index 368893b7..a18bd5ea 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdlibVoice.h +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdlibVoice.h @@ -43,11 +43,10 @@ namespace HyperSonicDrivers::drivers::midi::scummvm AdLibVoice* next; AdLibVoice* prev; - uint8_t waitForPedal; uint8_t slot; // NOTE: this is between 0 and 9, this is the "slot" (OPL channel number, not the MIDI Channel) uint8_t twoChan; - uint8_t vol1; - uint8_t vol2; + uint8_t vol1; // mod volume + uint8_t vol2; // car volume int16_t duration; Struct10 _s10a; @@ -64,5 +63,6 @@ namespace HyperSonicDrivers::drivers::midi::scummvm inline void setNote(const uint8_t note) { m_note = note; } inline void setFree(const bool free) { m_free = free; }; inline void setChannel(AdLibPart* chan) { m_channel = chan; }; + inline void setWaitForPedal(const bool waitForPedal) { m_sustain = waitForPedal; }; }; } diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp index 1c72604c..fdd3bcac 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp @@ -574,7 +574,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm if (value != 0) { for (AdLibVoice* voice = part->voice; voice; voice = voice->next) { - if (voice->waitForPedal) + if (voice->isSustain()) mcOff(voice); } } @@ -889,7 +889,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm if (voice->getNote() == note) { if (part->sustain) - voice->waitForPedal = true; + voice->setWaitForPedal(true); else mcOff(voice); } @@ -966,7 +966,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm voice->twoChan = instr->feedback & 1; voice->setNote(note); - voice->waitForPedal = false; + voice->setWaitForPedal(false); voice->duration = instr->duration; if (voice->duration != 0) voice->duration *= 63;