-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MidiDriver interface refactor (#256)
* init * code rev * midi interfaces WIP * midi drivers refactor * fix build * [wip] * [WIP] * OplDriver refactor * clean-ups * clean-ups * clean-ups * clean-ups * code rev * code refactor * code rev * coder ev * clean up scumm midi drv * clean up scumm midi drv * clean up scumm midi drv * clean up scumm midi drv * code rev * scummvm MidiDriver pitchbend * midi gm driver scummvm refactor * midi gm driver scummvm refactor * midi gm driver scummvm refactor * midi gm driver scummvm refactor * midi gm driver scummvm refactor * remove scummvm MidiDriver_BASE * midi driver scumm gm clean-ups * midi driver scumm gm clean-ups * midi driver scumm gm clean-ups * midi driver scumm gm clean-ups * midi driver scumm gm clean-ups * fix midi scumm gm adlib * code rev * code rev * code rev * code rev * code rev * code rev * sonarcloud code rev * code rev * code rev * code rev * code rev
- Loading branch information
Showing
35 changed files
with
1,245 additions
and
1,353 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannel.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <HyperSonicDrivers/drivers/midi/IMidiChannel.hpp> | ||
#include <HyperSonicDrivers/audio/midi/types.hpp> | ||
|
||
namespace HyperSonicDrivers::drivers::midi | ||
{ | ||
IMidiChannel::IMidiChannel(const uint8_t channel) : | ||
channel(channel), | ||
isPercussion(channel == audio::midi::MIDI_PERCUSSION_CHANNEL) | ||
{} | ||
} |
26 changes: 26 additions & 0 deletions
26
sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannel.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <HyperSonicDrivers/drivers/midi/IMidiChannelVoice.hpp> | ||
|
||
namespace HyperSonicDrivers::drivers::midi | ||
{ | ||
/** | ||
* Interface for MIDI operation to a specific MIDI Channel | ||
**/ | ||
class IMidiChannel | ||
{ | ||
public: | ||
explicit IMidiChannel(const uint8_t channel); | ||
virtual ~IMidiChannel() = default; | ||
|
||
const uint8_t channel; // MIDI channel number | ||
uint8_t volume = 0; // channel volume | ||
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; | ||
}; | ||
} |
22 changes: 22 additions & 0 deletions
22
sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannelVoice.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <HyperSonicDrivers/drivers/midi/IMidiChannelVoice.hpp> | ||
#include <HyperSonicDrivers/drivers/midi/IMidiChannel.hpp> | ||
#include <cmath> | ||
|
||
namespace HyperSonicDrivers::drivers::midi | ||
{ | ||
uint8_t IMidiChannelVoice::getChannelNum() const noexcept | ||
{ | ||
return m_channel->channel; | ||
} | ||
|
||
void IMidiChannelVoice::setVolumes(const uint8_t volume) noexcept | ||
{ | ||
m_volume = volume; | ||
m_real_volume = calcVolume_(); | ||
} | ||
|
||
uint8_t IMidiChannelVoice::calcVolume_() const noexcept | ||
{ | ||
return std::min<uint8_t>(static_cast<uint8_t>(m_volume * m_channel->volume / 127), 127); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/IMidiChannelVoice.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace HyperSonicDrivers::drivers::midi | ||
{ | ||
class IMidiChannel; | ||
|
||
/** | ||
* Interface for Midi Channel Voice message to have a polyphonic MidiChannel. | ||
* this is mono-phonic channel, multiple combination of this gives a polyphonic MidiChannel | ||
**/ | ||
class IMidiChannelVoice | ||
{ | ||
public: | ||
IMidiChannelVoice() = default; | ||
virtual ~IMidiChannelVoice() = default; | ||
|
||
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; }; | ||
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: | ||
IMidiChannel* m_channel = nullptr; // MIDI channel | ||
uint8_t m_note = 0; /* note number */ | ||
uint8_t m_volume = 0; /* note volume */ | ||
uint8_t m_real_volume = 0; /* adjusted note volume */ | ||
int16_t m_pitch_factor = 0; /* pitch-wheel value */ | ||
bool m_free = true; | ||
bool m_sustain = false; // this are Opl exclusive or are midi? | ||
bool m_vibrato = false; // "" | ||
|
||
private: | ||
/// <summary> | ||
/// The volume is between 0-127 as a per MIDI specification. | ||
/// OPLWriter expect a MIDI volume value and converts to OPL value. | ||
/// OPL chips has a volume attenuation (inverted values) | ||
/// range from 0-64 inverted (0 is max, 64 is muted). | ||
/// </summary> | ||
uint8_t calcVolume_() const noexcept; | ||
}; | ||
|
||
} |
Oops, something went wrong.