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 aFramesSignal
Mixer
allows multiple signals to be played concurrently and controlled during playbackSpatialScene
is a mixer that spatializes its signalsHandle
allows control of a signal while it's playing, from a mixer orsplit
run
writes frames from aSignal
into an output buffer
Structs
Cycle | Loops |
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 |
Handle | Handle for manipulating a signal owned elsewhere |
Here |
|
Mixer | |
MixerControl | Handle for controlling a |
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 |
Spatial | An individual spatialized signal |
SpatialControl | Control for updating the motion of a spatial signal |
SpatialScene |
|
SpatialSceneControl | Control for modifying a |
Speed | Scales rate of playback by a dynamically-adjustable factor |
SpeedControl | Thread-safe control for a |
SplitSignal | A concurrently controlled |
Stop | A source that can be paused or permanently stopped |
StopControl | Thread-safe control for a |
Stream | Dynamic audio from an external source |
StreamControl | Thread-safe control for a |
Swap | SPSC queue that only retains the last element sent |
There |
|
Traits
Controlled | A |
Filter | A wrapper which transforms a |
FilterHaving | Filter chains that contain a |
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 |
split | Split concurrent controls out of a signal |
Type Definitions
Sample | Unitless instantaneous sound wave amplitude measurement |