Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions envelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ class RESID_API EnvelopeGenerator
RESID_INLINE reg8 output();

protected:
reg16 rate_counter;
reg16 rate_period;
reg8 exponential_counter;
reg8 exponential_counter_period;
reg8 envelope_counter;
bool hold_zero;
reg16 rate_counter = 0;
reg16 rate_period = 0;
reg8 exponential_counter = 0;
reg8 exponential_counter_period = 0;
reg8 envelope_counter = 0;
bool hold_zero = false;

reg4 attack;
reg4 decay;
reg4 sustain;
reg4 release;
reg4 attack = 0;
reg4 decay = 0;
reg4 sustain = 0;
reg4 release = 0;

reg8 gate;
reg8 gate = 0;

State state;
State state = {};

// Lookup table to convert from attack, decay, or release value to rate
// counter period.
Expand Down
14 changes: 7 additions & 7 deletions extfilt.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ class RESID_API ExternalFilter

protected:
// Filter enabled.
bool enabled;
bool enabled = false;

// Maximum mixer DC offset.
sound_sample mixer_DC;
sound_sample mixer_DC = 0;

// State of filters.
sound_sample Vlp; // lowpass
sound_sample Vhp; // highpass
sound_sample Vo;
sound_sample Vlp = 0; // lowpass
sound_sample Vhp = 0; // highpass
sound_sample Vo = 0;

// Cutoff frequencies.
sound_sample w0lp;
sound_sample w0hp;
sound_sample w0lp = 0;
sound_sample w0hp = 0;

friend class SID;
};
Expand Down
36 changes: 19 additions & 17 deletions filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,48 +153,50 @@ class RESID_API Filter
void set_Q();

// Filter enabled.
bool enabled;
bool enabled = false;

// Filter cutoff frequency.
reg12 fc;
reg12 fc = 0;

// Filter resonance.
reg8 res;
reg8 res = 0;

// Selects which inputs to route through filter.
reg8 filt;
reg8 filt = 0;

// Switch voice 3 off.
reg8 voice3off;
reg8 voice3off = 0;

// Highpass, bandpass, and lowpass filter modes.
reg8 hp_bp_lp;
reg8 hp_bp_lp = 0;

// Output master volume.
reg4 vol;
reg4 vol = 0;

// Mixer DC offset.
sound_sample mixer_DC;
sound_sample mixer_DC = 0;

// State of filter.
sound_sample Vhp; // highpass
sound_sample Vbp; // bandpass
sound_sample Vlp; // lowpass
sound_sample Vnf; // not filtered
sound_sample Vhp = 0; // highpass
sound_sample Vbp = 0; // bandpass
sound_sample Vlp = 0; // lowpass
sound_sample Vnf = 0; // not filtered

// Cutoff frequency, resonance.
sound_sample w0, w0_ceil_1, w0_ceil_dt;
sound_sample _1024_div_Q;
sound_sample w0 = 0;
sound_sample w0_ceil_1 = 0;
sound_sample w0_ceil_dt = 0;
sound_sample _1024_div_Q = 0;

// Cutoff frequency tables.
// FC is an 11 bit register.
sound_sample f0_6581[2048];
sound_sample f0_8580[2048];
sound_sample* f0;
sound_sample* f0 = nullptr;
static fc_point f0_points_6581[];
static fc_point f0_points_8580[];
fc_point* f0_points;
int f0_count;
fc_point* f0_points = nullptr;
int f0_count = 0;

friend class SID;
};
Expand Down
62 changes: 32 additions & 30 deletions sid.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class RESID_API SID
public:
SID();
~SID();
SID(const SID &other) = delete; // prevent copying
SID& operator=(const SID& other) = delete; // prevent assignment

void set_chip_model(chip_model model);
void enable_filter(bool enable);
Expand Down Expand Up @@ -60,18 +62,18 @@ class RESID_API SID

char sid_register[0x20];

reg8 bus_value;
cycle_count bus_value_ttl;

reg24 accumulator[3];
reg24 shift_register[3];
reg16 rate_counter[3];
reg16 rate_counter_period[3];
reg16 exponential_counter[3];
reg16 exponential_counter_period[3];
reg8 envelope_counter[3];
EnvelopeGenerator::State envelope_state[3];
bool hold_zero[3];
reg8 bus_value = 0;
cycle_count bus_value_ttl = 0;

reg24 accumulator[3] = {};
reg24 shift_register[3] = {};
reg16 rate_counter[3] = {};
reg16 rate_counter_period[3] = {};
reg16 exponential_counter[3] = {};
reg16 exponential_counter_period[3] = {};
reg8 envelope_counter[3] = {};
EnvelopeGenerator::State envelope_state[3] = {};
bool hold_zero[3] = {};
};

State read_state();
Expand All @@ -96,19 +98,19 @@ class RESID_API SID
RESID_INLINE int clock_resample_fast(cycle_count& delta_t, short* buf,
int n, int interleave);

Voice voice[3];
Filter filter;
ExternalFilter extfilt;
Potentiometer potx;
Potentiometer poty;
Voice voice[3] = {};
Filter filter = {};
ExternalFilter extfilt = {};
Potentiometer potx = {};
Potentiometer poty = {};

reg8 bus_value;
cycle_count bus_value_ttl;
reg8 bus_value = {};
cycle_count bus_value_ttl = 0;

double clock_frequency;
double clock_frequency = 0;

// External audio input.
int ext_in;
int ext_in = 0;

// Resampling constants.
// The error in interpolated lookup is bounded by 1.234/L^2,
Expand All @@ -128,19 +130,19 @@ class RESID_API SID
static const int FIXP_MASK = 0xffff;

// Sampling variables.
sampling_method sampling;
cycle_count cycles_per_sample;
cycle_count sample_offset;
int sample_index;
short sample_prev;
int fir_N;
int fir_RES;
sampling_method sampling = {};
cycle_count cycles_per_sample = 0;
cycle_count sample_offset = 0;
int sample_index = 0;
short sample_prev = 0;
int fir_N = 0;
int fir_RES = 0;

// Ring buffer with overflow for contiguous storage of RINGSIZE samples.
short* sample;
short* sample = nullptr;

// FIR_RES filter tables (FIR_N*FIR_RES).
short* fir;
short* fir = nullptr;
};

#endif // not __SID_H__
8 changes: 4 additions & 4 deletions voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class RESID_API Voice
RESID_INLINE sound_sample output();

protected:
WaveformGenerator wave;
EnvelopeGenerator envelope;
WaveformGenerator wave = {};
EnvelopeGenerator envelope = {};

// Waveform D/A zero level.
sound_sample wave_zero;
sound_sample wave_zero = 0;

// Multiplying D/A DC offset.
sound_sample voice_DC;
sound_sample voice_DC = 0;

friend class SID;
};
Expand Down
30 changes: 15 additions & 15 deletions wave.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ class RESID_API WaveformGenerator
RESID_INLINE reg12 output();

protected:
const WaveformGenerator* sync_source;
WaveformGenerator* sync_dest;
const WaveformGenerator* sync_source = nullptr;
WaveformGenerator* sync_dest = nullptr;

// Tell whether the accumulator MSB was set high on this cycle.
bool msb_rising;
bool msb_rising = false;

reg24 accumulator;
reg24 shift_register;
reg24 accumulator = 0;
reg24 shift_register = 0;

// Fout = (Fn*Fclk/16777216)Hz
reg16 freq;
reg16 freq = 0;
// PWout = (PWn/40.95)%
reg12 pw;
reg12 pw = 0;

// The control register right-shifted 4 bits; used for output function
// table lookup.
reg8 waveform;
reg8 waveform = 0;

// The remaining control register bits.
reg8 test;
reg8 ring_mod;
reg8 sync;
reg8 test = 0;
reg8 ring_mod = 0;
reg8 sync = 0;
// The gate bit is handled by the EnvelopeGenerator.

// 16 possible combinations of waveforms.
Expand Down Expand Up @@ -107,10 +107,10 @@ class RESID_API WaveformGenerator
static reg8 wave8580_PS_[];
static reg8 wave8580_PST[];

reg8* wave__ST;
reg8* wave_P_T;
reg8* wave_PS_;
reg8* wave_PST;
reg8* wave__ST = nullptr;
reg8* wave_P_T = nullptr;
reg8* wave_PS_ = nullptr;
reg8* wave_PST = nullptr;

friend class Voice;
friend class SID;
Expand Down