Skip to content

Env

Envelope generator module.

This module provides an envelope generator class that can create complex envelopes with multiple segments, curves, and looping capabilities.

Structs

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

Initialize EnvParams. For information on the arguments, see the documentation of the Env::next() method that takes each parameter individually. 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 with an arbitrary number of segments.

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility


Env Functions

struct Env . fn init

Initialize the Env struct.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

fn init Returns : Self

Static Method

This is a static method.

struct Env . fn next

Generate the next envelope value. Args: values: List of envelope values at each breakpoint. times: List of durations (in seconds) for each segment between adjacent breakpoints. This List should be one element shorter than the values List. curves: 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 to indicate if the envelope should loop. trig: Trigger to start the envelope. time_warp: Time warp factor to speed up or slow down the envelope. Default is 1.0 meaning no warp. A value of 2.0 will make the envelop take twice as long to complete. A value of 0.5 will make the envelope take half as long to complete.

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 Env . fn next

Generate the next envelope value.

fn next Signature

next(mut self, ref params: EnvParams, trig: Bool = True) -> Float64

fn next Arguments

Name Type Default Description
params EnvParams An EnvParams containing the parameters for the envelope. For information on the parameters see the other Env::next() method that takes each parameter individually.
trig Bool True Trigger to start the envelope.

fn next Returns : Float64

struct ASREnv

Simple ASR envelope generator.

Traits: AnyType, Copyable, Movable, Representable, UnknownDestructibility


ASREnv Functions

struct ASREnv . fn init

Initialize the ASREnv struct.

fn init Signature

__init__(out self, world: UnsafePointer[MMMWorld])

fn init Arguments

Name Type Default Description
world UnsafePointer Pointer to the MMMWorld.

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 (Bool): Gate signal (True or False).
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

(Functions that are not associated with a Struct)

fn min_env

Simple envelope.

Envelope that rises linearly from 0 to 1 over rampdur seconds, stays at 1 until totaldur - rampdur, then falls linearly back to 0 over the final rampdur seconds. This envelope isn't "triggered," instead the user provides the current phase between 0 (beginning) and 1 (end) of the envelope.

Signature

min_env[N: Int = 1](phase: SIMD[DType.float64, N] = 0.01, totaldur: SIMD[DType.float64, N] = 0.10000000000000001, rampdur: SIMD[DType.float64, N] = 0.001) -> SIMD[DType.float64, N]

Parameters

Name Type Description
N Int

Arguments

Name Type Default Description
phase SIMD 0.01 Current env position between 0 (beginning) and 1 (end).
totaldur SIMD 0.10000000000000001 Total duration of the envelope.
rampdur SIMD 0.001 Duration of the rise and fall segments that occur at the beginning and end of the envelope.

Returns

Type: SIMD Envelope value at the current ramp position.


Documentation generated with mojo doc from Mojo version 0.25.6.1