Gate control and ADSR as elements

This commit is contained in:
Dejvino
2026-02-28 18:25:02 +01:00
parent db76f4fcef
commit 7ff85048df
3 changed files with 249 additions and 161 deletions
+4 -28
View File
@@ -68,25 +68,9 @@ public:
*/
float getFrequency() const;
/**
* @brief Configures the ADSR envelope.
* @param attack Attack time in seconds.
* @param decay Decay time in seconds.
* @param sustain Sustain level (0.0 to 1.0).
* @param release Release time in seconds.
*/
void setADSR(float attack, float decay, float sustain, float release);
/**
* @brief Configures the filters.
* @param lpCutoff Low-pass cutoff frequency in Hz.
* @param hpCutoff High-pass cutoff frequency in Hz.
*/
void setFilter(float lpCutoff, float hpCutoff);
// --- Grid Synth ---
struct GridCell {
enum Type { EMPTY, FIXED_OSCILLATOR, INPUT_OSCILLATOR, WAVETABLE, NOISE, LFO, FORK, WIRE, LPF, HPF, VCA, BITCRUSHER, DISTORTION, GLITCH, OPERATOR, DELAY, REVERB, SINK };
enum Type { EMPTY, FIXED_OSCILLATOR, INPUT_OSCILLATOR, WAVETABLE, NOISE, LFO, GATE, GATE_INPUT, ADSR_ATTACK, ADSR_DECAY, ADSR_SUSTAIN, ADSR_RELEASE, FORK, WIRE, LPF, HPF, VCA, BITCRUSHER, DISTORTION, RECTIFIER, PITCH_SHIFTER, GLITCH, OPERATOR, DELAY, REVERB, SINK };
enum Op { OP_ADD, OP_MUL, OP_SUB, OP_DIV, OP_MIN, OP_MAX };
Type type = EMPTY;
@@ -112,18 +96,10 @@ private:
float _volume;
Waveform _waveform;
bool _isGateOpen;
uint32_t _rngState;
// ADSR State
enum EnvState { ENV_IDLE, ENV_ATTACK, ENV_DECAY, ENV_SUSTAIN, ENV_RELEASE };
EnvState _envState;
float _envLevel;
float _attackInc, _decayDec, _sustainLevel, _releaseDec;
// Filter State
float _lpAlpha;
float _hpAlpha;
float _lpVal;
float _hpVal;
// Internal random number generator
float _random();
};
#endif // SYNTH_ENGINE_H