Crate oddio[][src]

Lightweight game audio

let (mut scene_handle, scene) = oddio::split(oddio::SpatialScene::new(sample_rate, 0.1));

// In audio callback:
let out_frames = oddio::frame_stereo(data);
oddio::run(&scene, output_sample_rate, out_frames);

// In game logic:
let frames = oddio::FramesSignal::from(oddio::Frames::from_slice(sample_rate, &frames));
let mut handle = scene_handle.control::<oddio::SpatialScene, _>()
    .play(frames, position, velocity, 1000.0);

// When position/velocity changes:
handle.control::<oddio::Spatial<_>, _>().set_motion(position, velocity);

Key primitives:

  • Frames stores static audio data, which can be played with a FramesSignal
  • Mixer allows multiple signals to be played concurrently and controlled during playback
  • SpatialScene is a mixer that spatializes its signals
  • Handle allows control of a signal while it's playing, from a mixer or split
  • run writes frames from a Signal into an output buffer

Structs

Cycle

Loops Frames end-to-end to construct a repeating signal

Frames

A sequence of static audio frames at a particular sample rate

FramesSignal

An audio signal backed by a static sequence of samples

Gain

Scales amplitude by a dynamically-adjustable factor

GainControl

Thread-safe control for a Gain filter

Handle

Handle for manipulating a signal owned elsewhere

Here

Index value for FilterHaving representing the first filter in the chain

Mixer

A Signal that mixes a dynamic set of Signals

MixerControl

Handle for controlling a Mixer from another thread

MonoToStereo

Adapt a mono signal to output stereo by duplicating its output

Reinhard

Smoothly maps a signal of any range into (-1, 1)

Sine

A trivial Signal that produces a sine wave of a particular frequency, forever

Spatial

An individual spatialized signal

SpatialControl

Control for updating the motion of a spatial signal

SpatialScene

Signal for stereo output from a spatial scene

SpatialSceneControl

Control for modifying a SpatialScene

Speed

Scales rate of playback by a dynamically-adjustable factor

SpeedControl

Thread-safe control for a Speed filter

SplitSignal

A concurrently controlled Signal

Stop

A source that can be paused or permanently stopped

StopControl

Thread-safe control for a Stop filter

Stream

Dynamic audio from an external source

StreamControl

Thread-safe control for a Stream

Swap

SPSC queue that only retains the last element sent

There

Index value for FilterHaving representing the filter at position T+1

Traits

Controlled

A Signal or transformer that can be safely controlled from another thread

Filter

A wrapper which transforms a Signal

FilterHaving

Filter chains that contain a T at any position

Frame

A single frame of audio data, encoding one sample for each channel

Signal

An audio signal

Functions

frame_stereo

Convert a slice of interleaved stereo data into a slice of stereo frames

run

Populate out with frames from signal at sample_rate

split

Split concurrent controls out of a signal

Type Definitions

Sample

Unitless instantaneous sound wave amplitude measurement