Skip to content

Commit

Permalink
clean-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello committed Sep 30, 2023
1 parent 833aabc commit eeb7274
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace HyperSonicDrivers::drivers::midi::opl
if (b)
{
setVolumes(value);
m_oplWriter->writeVolume(m_slot, m_instr, getRealVolume());
m_oplWriter->writeVolume(m_slot, m_instr, m_real_volume);
}

return b;
Expand Down Expand Up @@ -152,7 +152,7 @@ namespace HyperSonicDrivers::drivers::midi::opl
if (m_vibrato)
m_oplWriter->writeModulation(m_slot, m_instr, true);
m_oplWriter->writePan(m_slot, m_instr, m_channel->pan);
m_oplWriter->writeVolume(m_slot, m_instr, getRealVolume());
m_oplWriter->writeVolume(m_slot, m_instr, m_real_volume);
playNote(true);

return m_slot;
Expand Down Expand Up @@ -183,7 +183,7 @@ namespace HyperSonicDrivers::drivers::midi::opl
{
m_oplWriter->writeChannel(0x60, m_slot, m_instr->att_dec_1, m_instr->att_dec_2);
m_oplWriter->writeChannel(0x80, m_slot, m_instr->sust_rel_1, m_instr->sust_rel_2);
m_oplWriter->writeVolume(m_slot, m_instr, getRealVolume());
m_oplWriter->writeVolume(m_slot, m_instr, m_real_volume);
m_oplWriter->writePan(m_slot, getInstrument(), m_channel->pan);
}

Expand All @@ -198,6 +198,6 @@ namespace HyperSonicDrivers::drivers::midi::opl
void OplVoice::setVolumes(const uint8_t volume) noexcept
{
m_volume = volume;
setRealVolume(m_volume);
m_real_volume = calcVolume_();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ namespace HyperSonicDrivers::drivers::midi::opl
void resume() const noexcept;

void setVolumes(const uint8_t volume) noexcept;
inline void setRealVolume(const uint8_t volume) noexcept { m_real_volume = calcVolume_(); }
inline uint8_t getRealVolume() const noexcept { return m_real_volume; }
//
//inline IMidiChannel* getChannel() const noexcept { return m_channel; }
inline uint8_t getChannelNum() const noexcept { return m_channel->channel; }
inline const hardware::opl::OPL2instrument_t* getInstrument() const noexcept { return m_instr; }
Expand All @@ -61,16 +60,13 @@ namespace HyperSonicDrivers::drivers::midi::opl
inline uint8_t getSlot() const noexcept { return m_slot; }
inline bool isFree() const noexcept { return m_free; }
inline bool isSecondary() const noexcept { return m_secondary; }
inline bool isChannel(const uint8_t channel) const noexcept { return m_channel->channel == channel; }
inline bool isChannelBusy(const uint8_t channel) const noexcept { return isChannel(channel) && !m_free; }
inline bool isChannelBusy(const IMidiChannel* channel) const noexcept { return isChannelBusy(channel->channel); }
inline bool isChannelFree(uint8_t channel) const noexcept { return isChannel(channel) && m_free; }
inline bool isChannelFree(const IMidiChannel* channel) const noexcept { return isChannelFree(channel->channel); }
inline bool isVibrato() const noexcept { return m_vibrato; }
inline uint8_t getNote() const noexcept { return m_note; }

protected:
void setInstrument(const hardware::opl::OPL2instrument_t* instr) noexcept;
//inline uint8_t getRealVolume() const noexcept { return m_real_volume; }
//inline void setRealVolume(const uint8_t volume) noexcept { m_real_volume = calcVolume_(); }

private:
const uint8_t m_slot; /* OPL channel number */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ namespace HyperSonicDrivers::drivers::midi::opl

// 1st voice
EXPECT_FALSE(v1.isFree());
EXPECT_TRUE(v1.isChannelBusy(ch));
EXPECT_FALSE(v1.isChannelFree(ch));
EXPECT_EQ(v1.getChannel(), ch);

EXPECT_EQ(v1.getSlot(), 0);
Expand All @@ -112,15 +110,12 @@ namespace HyperSonicDrivers::drivers::midi::opl
const int cmpInstr1 = memcmp(&b->getInstrumentPtr(0)->voices[0], v1.getInstrument(), sizeof(hardware::opl::OPL2instrument_t));
EXPECT_EQ(cmpInstr1, 0);
EXPECT_TRUE(v1.isVibrato());
EXPECT_EQ(v1.getRealVolume(), ch_vol * vol / 127);
EXPECT_EQ(v1.getPitch(), ch_pitch);
EXPECT_EQ(v1.getPitchFactor(), ch_pitch);
EXPECT_EQ(v1.getPan(), ch_pan);

// 2nd voice
EXPECT_FALSE(v2.isFree());
EXPECT_TRUE(v2.isChannelBusy(ch));
EXPECT_FALSE(v2.isChannelFree(ch));
EXPECT_EQ(v2.getChannel(), ch);

EXPECT_EQ(v2.getSlot(), 1);
Expand All @@ -131,7 +126,6 @@ namespace HyperSonicDrivers::drivers::midi::opl
const int cmpInstr2 = memcmp(&b->getInstrumentPtr(0)->voices[1], v2.getInstrument(), sizeof(hardware::opl::OPL2instrument_t));
EXPECT_EQ(cmpInstr2, 0);
EXPECT_TRUE(v2.isVibrato());
EXPECT_EQ(v2.getRealVolume(), ch_vol * vol / 127);
EXPECT_EQ(v2.getPitch(), ch_pitch);
EXPECT_EQ(v2.getPitchFactor(), ch_pitch);
EXPECT_EQ(v2.getPan(), ch_pan);
Expand Down

0 comments on commit eeb7274

Please sign in to comment.