From da3adb4daa277169773bf7b6b062f7b9a9bc9872 Mon Sep 17 00:00:00 2001 From: Luke Usher Date: Sat, 21 Oct 2023 10:37:37 +0100 Subject: [PATCH] ym2612: update key state on phase tick --- ares/component/audio/ym2612/channel.cpp | 8 ++++---- ares/component/audio/ym2612/ym2612.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ares/component/audio/ym2612/channel.cpp b/ares/component/audio/ym2612/channel.cpp index 818c845ffd..29f25580fe 100644 --- a/ares/component/audio/ym2612/channel.cpp +++ b/ares/component/audio/ym2612/channel.cpp @@ -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 @@ -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; @@ -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 diff --git a/ares/component/audio/ym2612/ym2612.hpp b/ares/component/audio/ym2612/ym2612.hpp index 1eb57e8376..a2f295f55e 100644 --- a/ares/component/audio/ym2612/ym2612.hpp +++ b/ares/component/audio/ym2612/ym2612.hpp @@ -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;