Skip to content

Commit

Permalink
ym2612: update key state on phase tick
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeUsher committed Oct 21, 2023
1 parent 3ebfb44 commit da3adb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ares/component/audio/ym2612/channel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
auto YM2612::Channel::Operator::updateKeyState(bool state) -> void {
if(keyOn == state) return; //no change
keyOn = state;
auto YM2612::Channel::Operator::updateKeyState() -> void {
if(keyOn == keyLine) return; //no change
keyOn = keyLine;

if(keyOn) {
//restart phase and envelope generators
Expand All @@ -27,7 +27,6 @@ auto YM2612::Channel::Operator::updateKeyState(bool state) -> void {
}

auto YM2612::Channel::Operator::runEnvelope() -> void {
updateKeyState(keyLine);
if(ym2612.envelope.clock & (1 << envelope.divider) - 1) return;

u32 value = ym2612.envelope.clock >> envelope.divider;
Expand Down Expand Up @@ -56,6 +55,7 @@ auto YM2612::Channel::Operator::runEnvelope() -> void {
}

auto YM2612::Channel::Operator::runPhase() -> void {
updateKeyState();
phase.value += phase.delta; //advance wave position
if(!(ssg.enable && envelope.value >= 0x200)) return; //SSG loop check

Expand Down
2 changes: 1 addition & 1 deletion ares/component/audio/ym2612/ym2612.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct YM2612 {
Operator(Channel& channel) : channel(channel), ym2612(channel.ym2612) {}

//channel.cpp
auto updateKeyState(bool) -> void;
auto updateKeyState() -> void;

auto runEnvelope() -> void;
auto runPhase() -> void;
Expand Down

0 comments on commit da3adb4

Please sign in to comment.