C64: fix per-channel osc for 6581

This commit is contained in:
tildearrow 2022-06-24 03:26:00 -05:00
parent 522fecc635
commit e39a923b23
4 changed files with 19 additions and 3 deletions

View file

@ -109,14 +109,15 @@ const char* DivPlatformC64::getEffectName(unsigned char effect) {
} }
void DivPlatformC64::acquire(short* bufL, short* bufR, size_t start, size_t len) { 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<start+len; i++) { for (size_t i=start; i<start+len; i++) {
sid.clock(); sid.clock();
bufL[i]=sid.output(); bufL[i]=sid.output();
if (++writeOscBuf>=8) { if (++writeOscBuf>=8) {
writeOscBuf=0; writeOscBuf=0;
oscBuf[0]->data[oscBuf[0]->needle++]=sid.last_chan_out[0]>>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]>>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]>>5; oscBuf[2]->data[oscBuf[2]->needle++]=(sid.last_chan_out[2]-dcOff)>>5;
} }
} }
} }

View file

@ -60,6 +60,13 @@ SID::~SID()
delete[] fir; delete[] fir;
} }
// ----------------------------------------------------------------------------
// Get DC offset of channel.
// ----------------------------------------------------------------------------
sound_sample SID::get_dc(int ch) {
return voice[ch].getDC();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Mute/unmute channel. // Mute/unmute channel.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View file

@ -34,6 +34,7 @@ public:
sound_sample last_chan_out[3]; sound_sample last_chan_out[3];
sound_sample get_dc(int ch);
void set_is_muted(int ch, bool val); void set_is_muted(int ch, bool val);
void set_chip_model(chip_model model); void set_chip_model(chip_model model);
void enable_filter(bool enable); void enable_filter(bool enable);

View file

@ -38,6 +38,7 @@ public:
// Amplitude modulated waveform output. // Amplitude modulated waveform output.
// Range [-2048*255, 2047*255]. // Range [-2048*255, 2047*255].
RESID_INLINE sound_sample output(); RESID_INLINE sound_sample output();
RESID_INLINE sound_sample getDC();
protected: protected:
WaveformGenerator wave; WaveformGenerator wave;
@ -72,6 +73,12 @@ sound_sample Voice::output()
return (wave.output() - wave_zero)*envelope.output() + voice_DC; 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 // RESID_INLINING || defined(__VOICE_CC__)
#endif // not __VOICE_H__ #endif // not __VOICE_H__