From e39a923b23cd1d71c7aca18a671639b8af383e09 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 24 Jun 2022 03:26:00 -0500 Subject: [PATCH] C64: fix per-channel osc for 6581 --- src/engine/platform/c64.cpp | 7 ++++--- src/engine/platform/sound/c64/sid.cc | 7 +++++++ src/engine/platform/sound/c64/sid.h | 1 + src/engine/platform/sound/c64/voice.h | 7 +++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/engine/platform/c64.cpp b/src/engine/platform/c64.cpp index 3372c8203..a55b53906 100644 --- a/src/engine/platform/c64.cpp +++ b/src/engine/platform/c64.cpp @@ -109,14 +109,15 @@ const char* DivPlatformC64::getEffectName(unsigned char effect) { } void DivPlatformC64::acquire(short* bufL, short* bufR, size_t start, size_t len) { + int dcOff=sid.get_dc(0); for (size_t i=start; i=8) { writeOscBuf=0; - oscBuf[0]->data[oscBuf[0]->needle++]=sid.last_chan_out[0]>>5; - oscBuf[1]->data[oscBuf[1]->needle++]=sid.last_chan_out[1]>>5; - oscBuf[2]->data[oscBuf[2]->needle++]=sid.last_chan_out[2]>>5; + oscBuf[0]->data[oscBuf[0]->needle++]=(sid.last_chan_out[0]-dcOff)>>5; + oscBuf[1]->data[oscBuf[1]->needle++]=(sid.last_chan_out[1]-dcOff)>>5; + oscBuf[2]->data[oscBuf[2]->needle++]=(sid.last_chan_out[2]-dcOff)>>5; } } } diff --git a/src/engine/platform/sound/c64/sid.cc b/src/engine/platform/sound/c64/sid.cc index d6ebbb449..aaed90a5f 100644 --- a/src/engine/platform/sound/c64/sid.cc +++ b/src/engine/platform/sound/c64/sid.cc @@ -60,6 +60,13 @@ SID::~SID() delete[] fir; } +// ---------------------------------------------------------------------------- +// Get DC offset of channel. +// ---------------------------------------------------------------------------- +sound_sample SID::get_dc(int ch) { + return voice[ch].getDC(); +} + // ---------------------------------------------------------------------------- // Mute/unmute channel. // ---------------------------------------------------------------------------- diff --git a/src/engine/platform/sound/c64/sid.h b/src/engine/platform/sound/c64/sid.h index f6b392713..e8b0d5c6d 100644 --- a/src/engine/platform/sound/c64/sid.h +++ b/src/engine/platform/sound/c64/sid.h @@ -34,6 +34,7 @@ public: sound_sample last_chan_out[3]; + sound_sample get_dc(int ch); void set_is_muted(int ch, bool val); void set_chip_model(chip_model model); void enable_filter(bool enable); diff --git a/src/engine/platform/sound/c64/voice.h b/src/engine/platform/sound/c64/voice.h index d248f32ae..85b4fedec 100644 --- a/src/engine/platform/sound/c64/voice.h +++ b/src/engine/platform/sound/c64/voice.h @@ -38,6 +38,7 @@ public: // Amplitude modulated waveform output. // Range [-2048*255, 2047*255]. RESID_INLINE sound_sample output(); + RESID_INLINE sound_sample getDC(); protected: WaveformGenerator wave; @@ -72,6 +73,12 @@ sound_sample Voice::output() return (wave.output() - wave_zero)*envelope.output() + voice_DC; } +RESID_INLINE +sound_sample Voice::getDC() +{ + return voice_DC; +} + #endif // RESID_INLINING || defined(__VOICE_CC__) #endif // not __VOICE_H__