Envelope generator module.
This module provides an envelope generator class that can create complex envelopes with multiple segments, curves, and looping capabilities.
struct EnvParams¶
Parameters for the Env class.
This struct holds the parameters for the envelope generator. It
is not required to use the Env struct, but it might be convenient.
Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility
EnvParams Functions¶
struct EnvParams . fn init¶
fn init Signature
__init__(out self, values: List[Float64] = List[Float64](0, 0, Tuple[]()), times: List[Float64] = List[Float64](1, 1, Tuple[]()), curves: List[Float64] = List[Float64](1, Tuple[]()), loop: Bool = False, time_warp: Float64 = 1)
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| values | List |
List[Float64](0, 0, Tuple[]()) |
— |
| times | List |
List[Float64](1, 1, Tuple[]()) |
— |
| curves | List |
List[Float64](1, Tuple[]()) |
— |
| loop | Bool |
False |
— |
| time_warp | Float64 |
1 |
— |
fn init Returns
: Self
Static Method
This is a static method.
struct Env¶
Envelope generator.
Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility
Env Functions¶
struct Env . fn init¶
fn init Signature
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| world | UnsafePointer |
— | — |
fn init Returns
: Self
Static Method
This is a static method.
struct Env . fn next¶
Generate the next envelope sample.
fn next Signature
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| params | EnvParams |
— | — |
| trig | Bool |
True |
— |
fn next Returns
: Float64
struct Env . fn next¶
Generate the next envelope sample. Attributes: values (List[Float64]): List of envelope values at each segment. times (List[Float64]): List of durations for each segment. curves (List[Float64]): List of curve shapes for each segment. Positive values for convex "exponential" curves, negative for concave "logarithmic" curves. (if the output of the envelope is negative, the curve will be inverted) loop (Bool): Flag to indicate if the envelope should loop. time_warp (Float64): Time warp factor to speed up or slow down the envelope.
fn next Signature
next(mut self, ref values: List[Float64], ref times: List[Float64] = List[Float64](1, 1, Tuple[]()), ref curves: List[Float64] = List[Float64](1, Tuple[]()), loop: Bool = False, trig: Bool = True, time_warp: Float64 = 1) -> Float64
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| values | List |
— | — |
| times | List |
List[Float64](1, 1, Tuple[]()) |
— |
| curves | List |
List[Float64](1, Tuple[]()) |
— |
| loop | Bool |
False |
— |
| trig | Bool |
True |
— |
| time_warp | Float64 |
1 |
— |
fn next Returns
: Float64
struct Changed¶
Detect changes in a value.
Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility
Changed Functions¶
struct Changed . fn init¶
fn init Signature
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| initial | Bool |
False |
— |
fn init Returns
: Self
Static Method
This is a static method.
struct Changed . fn next¶
Check if the value has changed.
fn next Signature
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| val | Bool |
— | — |
fn next Returns
: Bool
struct ASREnv¶
Simple ASR envelope generator.
Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility
ASREnv Functions¶
struct ASREnv . fn init¶
fn init Signature
fn init Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| world | UnsafePointer |
— | — |
fn init Returns
: Self
Static Method
This is a static method.
struct ASREnv . fn next¶
Simple ASR envelope generator.
fn next Signature
next(mut self, attack: Float64, sustain: Float64, release: Float64, gate: Bool, curve: SIMD[DType.float64, 2] = 1) -> Float64
fn next Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| attack | Float64 |
— | (Float64): Attack time in seconds. |
| sustain | Float64 |
— | (Float64): Sustain level (0 to 1). |
| release | Float64 |
— | (Float64): Release time in seconds. |
| gate | Bool |
— | (Float64): Gate signal (0 or 1). |
| curve | SIMD |
1 |
(SIMD[DType.float64, 2]): Can pass a Float64 for equivalent curve on rise and fall or SIMD[DType.float64, 2] for different rise and fall curve. Positive values for convex "exponential" curves, negative for concave "logarithmic" curves. |
fn next Returns
: Float64
(Functions that are not associated with a Struct)
fn min_env¶
Create a simple envelope with specified ramp and duration. The rise and fall will be of length 'rise'.
Signature
min_env[N: Int = 1](ramp: SIMD[DType.float64, N] = 0.01, dur: SIMD[DType.float64, N] = 0.10000000000000001, rise: SIMD[DType.float64, N] = 0.001) -> SIMD[DType.float64, N]
Parameters
| Name | Type | Description |
|---|---|---|
| N | Int |
— |
Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| ramp | SIMD |
0.01 |
(SIMD[DType.float64, N]): Current ramp position (0 to 1). |
| dur | SIMD |
0.10000000000000001 |
(SIMD[DType.float64, N]): Total duration of the envelope. |
| rise | SIMD |
0.001 |
(SIMD[DType.float64, N]): Duration of the rise and fall segments. |
Returns
Type: SIMD
SIMD[DType.float64, N]: Envelope value at the current ramp position.
Documentation generated with mojo doc from Mojo version 0.25.6.1