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:
Framesstores static audio data, which can be played with aFramesSignalMixerallows multiple signals to be played concurrently and controlled during playbackSpatialSceneis a mixer that spatializes its signalsrunwrites frames from aSignalinto an output buffer
Structs
- Smoothly adjusts gain over time to keep average (RMS) signal level within a target range
- Configuration for an
Adaptfilter, passed toAdapt::new - A constant signal, useful for testing
- Loops
Framesend-to-end to construct a repeating signal - Sums all channels together
- Cross-fades smoothly between dynamically-supplied signals
- Thread-safe control for a
Faderfilter - Amplifies a signal by a constant amount
- A sequence of static audio frames at a particular sample rate
- An audio signal backed by a static sequence of samples
- Thread-safe control for a
FramesSignal, giving access to current playback location. - Amplifies a signal dynamically
- Thread-safe control for a
Gainfilter - Handle to a signal playing in a
Mixer - Handle for controlling a
Mixerfrom another thread - Adapts a mono signal to output stereo by duplicating its output
- Smoothly maps a signal of any range into (-1, 1)
- A trivial
Signalthat produces a sine wave of a particular frequency, forever - Helper to linearly ramp a parameter towards a target value
- Control for updating the motion of a spatial signal
- Passed to
SpatialSceneControl::play Signalfor stereo output from a spatial scene- Control for modifying a
SpatialScene - Scales rate of playback by a dynamically-adjustable factor
- Thread-safe control for a
Speedfilter - Dynamic audio from an external source
- Thread-safe control for a
Stream - Smoothly maps a signal of any range into (-1, 1)
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
outwith frames fromsignalatsample_rate
Type Aliases
- Unitless instantaneous sound wave amplitude measurement