23 #ifndef ENVELOPEGENERATOR_H
24 #define ENVELOPEGENERATOR_H
26 #include "siddefs-fp.h"
49 ATTACK, DECAY_SUSTAIN, RELEASE
62 int exponential_counter;
68 int exponential_counter_period;
88 bool envelope_pipeline;
94 unsigned char envelope_counter;
114 static const int adsrtable[16];
117 void set_exponential_counter();
139 short output()
const {
return dac[envelope_counter]; }
147 exponential_counter(0),
148 exponential_counter_period(1),
155 envelope_pipeline(false),
157 envelope_counter(0) {}
193 unsigned char readENV()
const {
return envelope_counter; }
198 #if RESID_INLINING || defined(ENVELOPEGENERATOR_CPP)
206 if (unlikely(envelope_pipeline))
209 envelope_pipeline =
false;
211 set_exponential_counter();
225 if (likely(lfsr != rate))
229 const int feedback = ((lfsr << 14) ^ (lfsr << 13)) & 0x4000;
230 lfsr = (lfsr >> 1) | feedback;
240 if (state == ATTACK || ++exponential_counter == exponential_counter_period)
243 exponential_counter = 0;
246 if (unlikely(hold_zero))
261 if (unlikely(envelope_counter == (
unsigned char) 0xff))
263 state = DECAY_SUSTAIN;
264 rate = adsrtable[decay];
277 if (likely(envelope_counter == (
unsigned char)(sustain << 4 | sustain)))
292 if (unlikely(exponential_counter_period != 1))
295 envelope_pipeline =
true;
304 set_exponential_counter();
void clock()
Definition: EnvelopeGenerator.h:204
void reset()
Definition: EnvelopeGenerator.cpp:120
void setChipModel(ChipModel chipModel)
Definition: EnvelopeGenerator.cpp:99
void writeCONTROL_REG(unsigned char control)
Definition: EnvelopeGenerator.cpp:141
short output() const
Definition: EnvelopeGenerator.h:139
unsigned char readENV() const
Definition: EnvelopeGenerator.h:193
EnvelopeGenerator()
Definition: EnvelopeGenerator.h:144
Definition: EnvelopeGenerator.h:40
void writeSUSTAIN_RELEASE(unsigned char sustain_release)
Definition: EnvelopeGenerator.cpp:186
void writeATTACK_DECAY(unsigned char attack_decay)
Definition: EnvelopeGenerator.cpp:171