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§

Adapt
Smoothly adjusts gain over time to keep average (RMS) signal level within a target range
AdaptOptions
Configuration for an Adapt filter, passed to Adapt::new
Constant
A constant signal, useful for testing
Cycle
Loops Frames end-to-end to construct a repeating signal
Downmix
Sums all channels together
Fader
Cross-fades smoothly between dynamically-supplied signals
FaderControl
Thread-safe control for a Fader filter
FixedGain
Amplifies a signal by a constant amount
Frames
A sequence of static audio frames at a particular sample rate
FramesSignal
An audio signal backed by a static sequence of samples
FramesSignalControl
Thread-safe control for a FramesSignal, giving access to current playback location.
Gain
Amplifies a signal dynamically
GainControl
Thread-safe control for a Gain filter
Mixed
Handle to a signal playing in a Mixer
Mixer
A Signal that mixes a dynamic set of Signals
MixerControl
Handle for controlling a Mixer from another thread
MonoToStereo
Adapts 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
Smoothed
Helper to linearly ramp a parameter towards a target value
Spatial
Control for updating the motion of a spatial signal
SpatialOptions
Passed to SpatialSceneControl::play
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
Stream
Dynamic audio from an external source
StreamControl
Thread-safe control for a Stream
Tanh
Smoothly maps a signal of any range into (-1, 1)

Traits§

Frame
A single frame of audio data, encoding one sample for each channel
Interpolate
Types that can be linearly interpolated, for use with Smoothed
Seek
Audio signals which support seeking
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

Type Aliases§

Sample
Unitless instantaneous sound wave amplitude measurement