From db06859d70db1ae60c3b70432b7e891407d8314d Mon Sep 17 00:00:00 2001 From: Devin Acker Date: Sat, 16 May 2026 11:01:18 -0400 Subject: sound/upd931: update pitch when writing either the note or octave registers (fixes regression with silent notes in ct8000 and related) (#15346) --- src/devices/sound/upd931.cpp | 61 ++++++++++++++++++++++++-------------------- src/devices/sound/upd931.h | 1 + 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/devices/sound/upd931.cpp b/src/devices/sound/upd931.cpp index 2a5c3d53f98..00de315c035 100644 --- a/src/devices/sound/upd931.cpp +++ b/src/devices/sound/upd931.cpp @@ -256,39 +256,17 @@ void upd931_device::sync_w(int state) /**************************************************************************/ void upd931_device::note_w(offs_t offset, u8 data) { - m_voice[offset].m_note = data; + voice_t &voice = m_voice[offset]; + voice.m_note = data; + update_pitch(voice); } /**************************************************************************/ void upd931_device::octave_w(offs_t offset, u8 data) { voice_t &voice = m_voice[offset]; - voice.m_octave = m_data; - - if (voice.m_note >= 0x2 && voice.m_note <= 0xe) - { - const u8 note = voice.m_note - 2; - u8 octave = voice.m_octave & 7; - - if (octave >= 2) - octave -= 2; // octave values 0-1 are the same as 2-3 - - /* - setting bit 3 of the octave reduces the duty cycle of individual notes, which is - implemented here by changing which part of the phase counter to use as the sample address. - ct8000 uses this for a few of its presets to produce a simple key-scaling effect. - */ - if (BIT(voice.m_octave, 3)) - voice.m_timbre_shift = 3 - octave; - else - voice.m_timbre_shift = 0; - - voice.m_pitch = m_pitch[octave * 12 + note]; - } - else - { - voice.m_pitch = 0; - } + voice.m_octave = data; + update_pitch(voice); } /**************************************************************************/ @@ -369,6 +347,35 @@ void upd931_device::reset_timer() m_retrig_timer->adjust(period, 0, period); } +/**************************************************************************/ +void upd931_device::update_pitch(voice_t &voice) +{ + if (voice.m_note >= 0x2 && voice.m_note <= 0xe) + { + const u8 note = voice.m_note - 2; + u8 octave = voice.m_octave & 7; + + if (octave >= 2) + octave -= 2; // octave values 0-1 are the same as 2-3 + + /* + setting bit 3 of the octave reduces the duty cycle of individual notes, which is + implemented here by changing which part of the phase counter to use as the sample address. + ct8000 uses this for a few of its presets to produce a simple key-scaling effect. + */ + if (BIT(voice.m_octave, 3)) + voice.m_timbre_shift = 3 - octave; + else + voice.m_timbre_shift = 0; + + voice.m_pitch = m_pitch[octave * 12 + note]; + } + else + { + voice.m_pitch = 0; + } +} + /**************************************************************************/ void upd931_device::update_env(voice_t &voice) { diff --git a/src/devices/sound/upd931.h b/src/devices/sound/upd931.h index ea982ac5b58..0ad5dde924f 100644 --- a/src/devices/sound/upd931.h +++ b/src/devices/sound/upd931.h @@ -113,6 +113,7 @@ private: void note_on(voice_t &voice); void reset_timer(); + void update_pitch(voice_t &voice); void update_env(voice_t &voice); void update_wave(voice_t &voice); -- cgit v1.2.3