Crate oddio

source ·
Expand description

Lightweight game audio

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

// In audio callback:
let out_frames = oddio::frame_stereo(data);
oddio::run(&mut 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
    .play(frames, oddio::SpatialOptions { position, velocity, ..Default::default() });

// When position/velocity changes:
handle.set_motion(position, velocity, false);

To get started, review the examples subdirectory in the crate source.

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
  • run writes frames from a Signal into an output buffer

Structs

Traits

  • A single frame of audio data, encoding one sample for each channel
  • Types that can be linearly interpolated, for use with Smoothed
  • Audio signals which support seeking
  • An audio signal

Functions

  • Convert a slice of interleaved stereo data into a slice of stereo frames
  • Populate out with frames from signal at sample_rate

Type Aliases

  • Unitless instantaneous sound wave amplitude measurement