Crate oddio[−][src]
Lightweight game audio
let (mut scene_handle, scene) = oddio::spatial(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.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 manipulation of a signal while it's played on aSpatialScene
orMixer
run
writes frames from aSignal
into an output buffer
Structs
Cycle | Loops |
ErasedSignal | Type-erased signal for which a |
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 |
Handle | Handle for manipulating a signal owned elsewhere |
Here |
|
Mixer | A |
MixerHandle | 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 |
|
SpatialSceneHandle | Handle for modifying a spatial scene |
Speed | Scales rate of playback by a dynamically-adjustable factor |
StreamReceiver | Handle for sampling from a stream |
StreamSender | Handle for submitting new samples to a stream |
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 |
mixer | Build a mixer and a handle for controlling it |
run | Populate |
spatial | Create a |
stream | Construct an unbounded stream of dynamic audio |
Type Definitions
Sample | Unitless instantaneous sound wave amplitude measurement |