ADSR and filters
This commit is contained in:
@@ -66,6 +66,22 @@ 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);
|
||||
|
||||
private:
|
||||
uint32_t _sampleRate;
|
||||
uint32_t _phase; // Phase accumulator for the oscillator.
|
||||
@@ -73,6 +89,18 @@ private:
|
||||
float _volume;
|
||||
Waveform _waveform;
|
||||
bool _isGateOpen;
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
#endif // SYNTH_ENGINE_H
|
||||
Reference in New Issue
Block a user