Standard Library

std.audio

Blocking native synth helpers for generated audio.

Exported functions

pub def envelope(attack_ms: Int, decay_ms: Int, sustain_level: Float, release_ms: Int) -> Envelope

Create an ADSR envelope in milliseconds.

pub def default_envelope() -> Envelope

Return the default short musical envelope.

pub def tone_with(frequency_hz: Float, duration_ms: Int, waveform: String, volume: Float, envelope_value: Envelope, vibrato_rate_hz: Float, vibrato_depth_hz: Float) -> Tone

Create a tone with explicit waveform, volume, envelope, and vibrato.

pub def tone(frequency_hz: Float, duration_ms: Int) -> Tone

Create a sine tone with the default envelope.

pub def rest(duration_ms: Int) -> Tone

Create a silent rest.

pub def render_sequence(tones: List[Tone], sample_rate: Int) -> AudioBuffer

Render a sequence of tones into signed 16-bit mono PCM samples.

pub def play_buffer(buffer: AudioBuffer) -> Void

Play a rendered audio buffer through the default native output device. Set NO_AUDIO=1 to skip native output while keeping rendering active.

pub def play_sequence(tones: List[Tone]) -> Void

Render and play a sequence using the default 44.1 kHz sample rate.