27 #ifndef AUDIO_SOFTSYNTH_SID_H 28 #define AUDIO_SOFTSYNTH_SID_H 30 #include "common/scummsys.h" 33 #define RESID_INLINE inline 44 typedef unsigned int reg4;
45 typedef unsigned int reg8;
46 typedef unsigned int reg12;
47 typedef unsigned int reg16;
48 typedef unsigned int reg24;
50 typedef int cycle_count;
51 typedef int sound_sample;
53 typedef unsigned char data8;
54 typedef unsigned short data16;
55 typedef unsigned short fc_point[2];
64 void updateClock(cycle_count delta_t);
68 void writeFREQ_LO(reg8);
69 void writeFREQ_HI(reg8);
70 void writePW_LO(reg8);
71 void writePW_HI(reg8);
72 void writeCONTROL_REG(reg8);
122 static const data8 wave6581__ST[];
123 static const data8 wave6581_P_T[];
124 static const data8 wave6581_PS_[];
125 static const data8 wave6581_PST[];
135 void enable_filter(
bool enable);
137 void updateClock(cycle_count delta_t,
138 sound_sample voice1, sound_sample voice2, sound_sample voice3);
142 void writeFC_LO(reg8);
143 void writeFC_HI(reg8);
144 void writeRES_FILT(reg8);
145 void writeMODE_VOL(reg8);
148 sound_sample output();
176 sound_sample mixer_DC;
185 sound_sample w0, w0_ceil_1, w0_ceil_dt;
186 sound_sample _1024_div_Q;
190 sound_sample f0_6581[2048];
192 static const fc_point f0_points_6581[];
193 const fc_point* f0_points;
203 enum State { ATTACK, DECAY_SUSTAIN, RELEASE };
205 void updateClock(cycle_count delta_t);
208 void writeCONTROL_REG(reg8);
209 void writeATTACK_DECAY(reg8);
210 void writeSUSTAIN_RELEASE(reg8);
219 reg8 exponential_counter;
220 reg8 exponential_counter_period;
221 reg8 envelope_counter;
235 static const data16 rate_counter_period[];
238 static const data8 sustain_level[];
247 void enable_filter(
bool enable);
248 void set_sampling_parameter(
double pass_freq);
250 void updateClock(cycle_count delta_t, sound_sample Vi);
254 sound_sample output();
261 sound_sample mixer_DC;
279 void set_sync_source(
Voice *);
282 void writeCONTROL_REG(reg8);
286 sound_sample output() {
288 return (wave.output() - wave_zero)*envelope.output() + voice_DC;
296 sound_sample wave_zero;
299 sound_sample voice_DC;
310 void enable_filter(
bool enable);
311 void enable_external_filter(
bool enable);
312 bool set_sampling_parameters(
double clock_freq,
313 double sample_freq,
double pass_freq = -1,
314 double filter_scale = 0.97);
316 void updateClock(cycle_count delta_t);
317 int updateClock(cycle_count& delta_t,
short* buf,
int n,
int interleave = 1);
321 reg8 read(reg8 offset);
322 void write(reg8 offset, reg8 value);
333 cycle_count bus_value_ttl;
335 double clock_frequency;
338 static const int FIXP_SHIFT;
339 static const int FIXP_MASK;
342 cycle_count cycles_per_sample;
343 cycle_count sample_offset;
349 #endif // not AUDIO_SOFTSYNTH_SID_H