Skip to content

Commit

Permalink
code rev
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello committed Oct 3, 2023
1 parent e89c55f commit a3ffcad
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <cstdint>
//#include <list>
#include <HyperSonicDrivers/drivers/midi/IMidiChannelVoice.hpp>

namespace HyperSonicDrivers::drivers::midi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ namespace HyperSonicDrivers::drivers::midi

void IMidiDriver::send(const audio::midi::MIDIEvent& e) noexcept
{
// TODO review, this might be the master send.
// so it can address also SysEx commands
// TODO: change that sysEx is a normal send event
// TODO: sysEx must be reviewed if ok, probably shoudl check
// also if last byte is meta sysEx end ...
using audio::midi::TO_HIGH;
using audio::midi::MIDI_EVENT_TYPES_HIGH;

Expand Down Expand Up @@ -117,14 +116,10 @@ namespace HyperSonicDrivers::drivers::midi
ctrl_sustain(chan, value);
break;
case REVERB:
// Effects level. Not supported.
//effectLevel(value);
logW(std::format("effect level value {}", value));
ctrl_reverb(chan, value);
break;
case CHORUS:
// Chorus level. Not supported.
//chorusLevel(value);
logW(std::format("chorus level value {}", value));
ctrl_chorus(chan, value);
break;
case RESET_ALL_CONTROLLERS:
// reset all controllers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,8 @@

namespace HyperSonicDrivers::drivers::midi::opl
{
OplChannel::OplChannel(const uint8_t channel/*, std::vector<std::unique_ptr<OplVoice>>& voices*/) :
IMidiChannel(channel)/*, m_oplVoices(voices)*/
OplChannel::OplChannel(const uint8_t channel) :
IMidiChannel(channel)
{
}

//void OplChannel::noteOff(const uint8_t note) noexcept
//{
// /*for (auto it = m_voices.begin(); it!=m_voices.end();)
// {
// auto& v = dynamic_cast<OplVoice&>(*it);
// if (v.noteOff(note, sustain))
// m_voices.erase(it);
// else
// ++it;
// }*/
//}

//void OplChannel::noteOn(const uint8_t note, const uint8_t vol) noexcept
//{
//
//}
//
//void OplChannel::controller(const uint8_t ctrl, uint8_t value) noexcept
//{
//}
//
//void OplChannel::programChange(const uint8_t program) noexcept
//{
//}
//
//void OplChannel::pitchBend(const uint16_t bend) noexcept
//{
//}
//
//int OplChannel::allocateVoice(const uint8_t slot, const uint8_t channel, const uint8_t note, const uint8_t volume, const audio::opl::banks::Op2BankInstrument_t* instrument, const bool secondary) noexcept
//{
// //OplVoice v()
// //return m_voices[slot]->allocate(this, ch, note, volume, instrument, secondary);
// return -1;
//}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <cstdint>
//#include <vector>
#include <HyperSonicDrivers/drivers/midi/IMidiChannel.hpp>
#include <HyperSonicDrivers/audio/opl/banks/OP2Bank.hpp>
#include <HyperSonicDrivers/drivers/midi/opl/OplVoice.hpp>
Expand All @@ -11,22 +10,6 @@ namespace HyperSonicDrivers::drivers::midi::opl
class OplChannel : public IMidiChannel
{
public:
explicit OplChannel(const uint8_t channel/*, std::vector<std::unique_ptr<OplVoice>>& voices*/);

protected:
//void noteOff(const uint8_t note) noexcept override;
//void noteOn(const uint8_t note, const uint8_t vol) noexcept override;
//void controller(const uint8_t ctrl, uint8_t value) noexcept override;
//void programChange(const uint8_t program) noexcept override;
//void pitchBend(const uint16_t bend) noexcept override;

private:
//std::vector<std::unique_ptr<OplVoice>>& m_oplVoices;
//audio::opl::banks::Op2BankInstrument_t* m_instrPtr = nullptr;

//int allocateVoice(const uint8_t slot, const uint8_t channel,
// const uint8_t note, const uint8_t volume,
// const audio::opl::banks::Op2BankInstrument_t* instrument,
// const bool secondary) noexcept;
explicit OplChannel(const uint8_t channel);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace HyperSonicDrivers::drivers::midi::opl
}

for (uint8_t i = 0; i < audio::midi::MIDI_MAX_CHANNELS; ++i) {
m_channels[i] = std::make_unique<OplChannel>(i/*, m_voices*/);
m_channels[i] = std::make_unique<OplChannel>(i);
}
}

Expand Down Expand Up @@ -116,7 +116,7 @@ namespace HyperSonicDrivers::drivers::midi::opl

for (auto it = m_voicesInUseIndex.begin(); it != m_voicesInUseIndex.end();)
{
if (m_voices[*it]->getChannelNum() == chan && m_voices[*it]->noteOff(/*chan,*/ note, sustain))
if (m_voices[*it]->getChannelNum() == chan && m_voices[*it]->noteOff(note, sustain))
{
m_voicesFreeIndex.push_back(*it);
it = m_voicesInUseIndex.erase(it);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ namespace HyperSonicDrivers::drivers::midi::opl

inline void setOP2Bank(const std::shared_ptr<audio::opl::banks::OP2Bank>& op2Bank) noexcept { m_op2Bank = op2Bank; };

//void send(const audio::midi::MIDIEvent& e) noexcept override;
//void send(uint32_t msg) noexcept override;
//void send(int8_t channel, uint32_t msg) noexcept override;

void pause() const noexcept override;
void resume() const noexcept override;

Expand All @@ -49,13 +45,9 @@ namespace HyperSonicDrivers::drivers::midi::opl
protected:
void onCallback() noexcept override;

// TODO: every MIDI function that has channel put into IMidiChannel interface
// ------
// MIDI Events
void noteOff(const uint8_t chan, const uint8_t note) noexcept override;
void noteOn(const uint8_t chan, const uint8_t note, const uint8_t vol) noexcept override;
//void controller(const uint8_t chan, const uint8_t ctrl, uint8_t value) noexcept override;
//void programChange(const uint8_t chan, const uint8_t program) noexcept override;
void pitchBend(const uint8_t chan, const uint16_t bend) noexcept override;

// MIDI Controller Events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm
class AdLibPart : public IMidiChannel
{
public:
AdLibPart(const uint8_t channel);
explicit AdLibPart(const uint8_t channel);

inline const AdLibInstrument* getInstr() const noexcept { return &_partInstr; };
inline const AdLibInstrument* getInstrSecondary() const noexcept { return &_partInstrSecondary; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm

return opl->getOpl();
}()),
m_opl3Mode(m_opl->type == OplType::OPL3)
m_opl3Mode(m_opl->type != OplType::OPL2)
{
using audio::midi::MIDI_PERCUSSION_CHANNEL;
using audio::midi::MIDI_MAX_CHANNELS;
Expand Down Expand Up @@ -337,7 +337,6 @@ namespace HyperSonicDrivers::drivers::midi::scummvm
if (!m_opl3Mode)
{
inst = m_percussion->getInstrument(note);
note_ = m_percussion->getNote(note_);
}

if (!inst)
Expand Down Expand Up @@ -432,11 +431,10 @@ namespace HyperSonicDrivers::drivers::midi::scummvm

void MidiDriver_ADLIB::programChange(const uint8_t chan, const uint8_t program) noexcept
{
auto part = getChannel(chan);

if (program > 127)
return;

auto part = getChannel(chan);
part->program = program;
part->setInstr(m_opl3Mode);
}
Expand Down

0 comments on commit a3ffcad

Please sign in to comment.