23 #ifndef ENVELOPEGENERATOR_H
24 #define ENVELOPEGENERATOR_H
26 #include "siddefs-fp.h"
51 ATTACK, DECAY_SUSTAIN, RELEASE
65 int exponential_counter;
71 int exponential_counter_period;
91 bool envelope_pipeline;
97 unsigned char envelope_counter;
118 static const int adsrtable[16];
121 void set_exponential_counter();
143 short output()
const {
return dac[envelope_counter]; }
151 exponential_counter(0),
152 exponential_counter_period(1),
159 envelope_pipeline(false),
161 envelope_counter(0) {}
197 unsigned char readENV()
const {
return envelope_counter; }
202 #if RESID_INLINING || defined(ENVELOPEGENERATOR_CPP)
210 if (unlikely(envelope_pipeline))
213 envelope_pipeline =
false;
215 set_exponential_counter();
229 if (likely(lfsr != rate))
233 const int feedback = ((lfsr << 14) ^ (lfsr << 13)) & 0x4000;
234 lfsr = (lfsr >> 1) | feedback;
244 if (state == ATTACK || ++exponential_counter == exponential_counter_period)
247 exponential_counter = 0;
250 if (unlikely(hold_zero))
265 if (unlikely(envelope_counter == 0xff))
267 state = DECAY_SUSTAIN;
268 rate = adsrtable[decay];
281 if (likely(envelope_counter == (sustain << 4 | sustain)))
296 if (unlikely(exponential_counter_period != 1))
299 envelope_pipeline =
true;
308 set_exponential_counter();
void clock()
Definition: EnvelopeGenerator.h:208
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:143
unsigned char readENV() const
Definition: EnvelopeGenerator.h:197
EnvelopeGenerator()
Definition: EnvelopeGenerator.h:148
Definition: EnvelopeGenerator.h:42
void writeSUSTAIN_RELEASE(unsigned char sustain_release)
Definition: EnvelopeGenerator.cpp:190
void writeATTACK_DECAY(unsigned char attack_decay)
Definition: EnvelopeGenerator.cpp:175