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 aFramesSignal
Mixer
allows multiple signals to be played concurrently and controlled during playbackSpatialScene
is a mixer that spatializes its signalsrun
writes frames from aSignal
into an output buffer
Structs
- Smoothly adjusts gain over time to keep average (RMS) signal level within a target range
- Configuration for an
Adapt
filter, passed toAdapt::new
- A constant signal, useful for testing
- Loops
Frames
end-to-end to construct a repeating signal - Sums all channels together
- Cross-fades smoothly between dynamically-supplied signals
- Thread-safe control for a
Fader
filter - 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
Gain
filter - Handle to a signal playing in a
Mixer
- Handle for controlling a
Mixer
from 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
Signal
that 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
Signal
for 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
Speed
filter - 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
out
with frames fromsignal
atsample_rate
Type Aliases
- Unitless instantaneous sound wave amplitude measurement