Class thl::dsp::utils::HannWindow#
-
class HannWindow#
HannWindow envelope generator class.
This class implements a Hann (raised cosine) window function for granular synthesis. It provides a smooth bell-shaped envelope that is particularly well-suited for grain envelopes in granular synthesis as it eliminates discontinuities at the grain boundaries.
Public Types
-
enum class State#
HannWindow envelope state.
Values:
-
enumerator IDLE#
-
enumerator ACTIVE#
-
enumerator IDLE#
Public Functions
-
HannWindow()#
-
void set_duration(float duration_ms)#
Set the total window duration.
- Parameters:
duration_ms – Duration of the window in milliseconds
-
void set_sample_rate(float sample_rate)#
Set sample rate for timing calculations.
- Parameters:
sample_rate – The sample rate in Hz
-
void start()#
Start the envelope.
-
void reset()#
Reset the envelope to IDLE state.
-
float process()#
Process a single sample and return the envelope value at the current position.
- Returns:
The current envelope amplitude (0.0-1.0)
-
float process_at_position(float position)#
Process a sample at a specific normalized position in the window.
- Parameters:
position – Normalized position in the window (0.0-1.0)
- Returns:
The envelope amplitude at the given position (0.0-1.0)
-
bool is_active() const#
Check if the envelope is active.
- Returns:
True if the envelope is active
-
enum class State#