Skip to main content

Crate aire

Crate aire 

Source
Expand description

A real-time audio engine for games and interactive applications.

§Quick start

use aire::{Engine, Sound, Oscillator, Waveform};

let engine = Engine::new()?;
let rate = engine.sample_rate();

let osc = Oscillator::new(Waveform::Sine, 440.0, rate).duration(2000);
let _handle = engine.add_sound(Sound::new(osc, rate))?;

§Key types

  • Engine — opens the output device and drives the audio thread
  • EngineConfig — optional configuration (command buffer size, etc.)
  • Sound — wraps a source with volume, pan, and an effect chain
  • SoundHandle — controls a playing sound from any thread
  • GroupHandle — controls volume and pan for a named category of sounds
  • Source — trait for anything that produces audio
  • Effect — trait for DSP effects
  • FileSource — loads or streams WAV, OGG, FLAC, and MP3 files
  • Oscillator — band-limited synthesized waveform source with six shapes
  • Adsr — ADSR amplitude envelope with linear or exponential curves
  • DecodePool — background thread pool for streaming decode. Only needed when using FileSource::stream.

Structs§

Adsr
An ADSR (Attack, Decay, Sustain, Release) amplitude envelope effect. Shapes the volume of a sound over time. All time values are in milliseconds, sustain amplitude is in decibels.
DecodePool
A pool of background threads that incrementally decode streaming audio into ring buffers.
Engine
The audio engine. Opens the default output device and drives the mixer on a real-time audio thread. All communication with the audio thread is lock-free and safe to call from any thread.
EngineConfig
Configuration for the audio engine.
FileSource
Plays audio from a file. Use FileSource::load for short sounds and FileSource::stream for music or long ambience tracks.
GroupHandle
A handle for controlling a group of sounds by category (e.g. "music", "sfx"). Obtained from crate::Engine::group. All methods return AireError::CommandBufferFull if the command queue is full.
Oscillator
A band-limited oscillator with six waveforms.
Sound
A playable sound with volume, pan, and an optional effect chain.
SoundHandle
A handle for controlling a sound after it has been added to the engine. Obtained from crate::Engine::add_sound. All methods return AireError::CommandBufferFull if the command queue is full.

Enums§

AireError
Errors returned by aire.
Curve
Shape of the attack and release envelope segments.
Waveform
The waveform shape produced by an Oscillator.

Traits§

Effect
A DSP effect that processes stereo samples. Implement this to create custom effects and add them to a crate::Sound via crate::Sound::add_effect.
Source
A source of audio samples. Can be a file, a synthesized signal, or anything that produces stereo output.