diff options
| author | 2026-05-16 11:01:18 -0400 | |
|---|---|---|
| committer | 2026-05-16 11:01:18 -0400 | |
| commit | db06859d70db1ae60c3b70432b7e891407d8314d (patch) | |
| tree | b551bea372d717798613db6302e2fea580478f10 | |
| parent | 17ea65c1ad0196f2cf7443ca293dede7818329ca (diff) | |
sound/upd931: update pitch when writing either the note or octave registers (fixes regression with silent notes in ct8000 and related) (#15346)
| -rw-r--r-- | src/devices/sound/upd931.cpp | 61 | ||||
| -rw-r--r-- | 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); } /**************************************************************************/ @@ -370,6 +348,35 @@ void upd931_device::reset_timer() } /**************************************************************************/ +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) { const unsigned shift = BIT(m_flags, FLAG_ENV_SHIFT, 2); 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); |
