You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
447 B
26 lines
447 B
#include "synth/dsp/adsr.h"
|
|
|
|
const ADSR::Envelope ADSR::DEFAULT_ENVELOPE = {
|
|
.attackStep = 1,
|
|
.decayStep = 1,
|
|
.sustain = 1,
|
|
.releaseStep = 1
|
|
};
|
|
|
|
ADSR::ADSR() {
|
|
this->envelope = &DEFAULT_ENVELOPE;
|
|
this->state = IDLE;
|
|
this->gain = 0;
|
|
}
|
|
|
|
void ADSR::setEnvelope(const Envelope* envelope) {
|
|
this->envelope = envelope;
|
|
}
|
|
|
|
void ADSR::noteOn() {
|
|
state = ATTACK;
|
|
}
|
|
|
|
void ADSR::noteOff() {
|
|
state = RELEASE;
|
|
}
|
|
|