Expand description
§Compose and play 3D audio.
The ambisonic library provides 3D sound scene support on top of rodio.
It allows positioning and moving sound sources freely in 3D space around a virtual listener,
and playing the resulting spatial mix in real-time over a sound card.
§Features:
- Realistic directional audio
- Take
rodiosound sources and place them in space - Doppler effect on moving sounds
§Usage Example
use std::thread::sleep;
use std::time::Duration;
use ambisonic::{rodio, AmbisonicBuilder};
let scene = AmbisonicBuilder::default().build();
let source = rodio::source::SineWave::new(440);
let mut sound = scene.play_at(source, [50.0, 1.0, 0.0]);
// move sound from right to left
sound.set_velocity([-10.0, 0.0, 0.0]);
for i in 0..1000 {
sound.adjust_position([50.0 - i as f32 / 10.0, 1.0, 0.0]);
sleep(Duration::from_millis(10));
}
sound.set_velocity([0.0, 0.0, 0.0]);§Technical Details
ambisonic is built around the concept of an intermediate representation of the sound field,
called B-format. The B-format describes what the listener should hear, independent of
their audio playback equipment. This leads to a clear separation of audio scene composition and
rendering. For details, see Wikipedia.
In its current state, the library allows spatial composition of single-channel rodio sources
into a first-order B-format stream. The chosen renderer then decodes the B-format stream
into audio signals for playback.
Currently, the following renderers are available:
- Stereo: simple and efficient playback on two stereo speakers or headphones
- HRTF: realistic 3D sound over headphones using head related transfer functions
Although at the moment only stereo output is supported, the B-format abstraction should make it easy to implement arbitrary speaker configurations in the future.
Re-exports§
pub use rodio;
Modules§
Structs§
- Ambisonic
- High-level Ambisonic Context.
- Ambisonic
Builder - A builder object for creating
Ambisoniccontexts - Bmixer
Composer - Compose the 3D sound scene
- Bstream
- Spatial source
- Bstream
Config - Initial configuration for constructing
Bstreams - Bstream
Hrtf Renderer - Render a B-format stream for headphones using head related transfer functions.
- Bstream
Mixer - Combine all currently playing 3D sound sources into a single B-format stream.
- Bstream
Stereo Renderer - Render a B-format stream to a stereo representation.
- Hrtf
Config - Head-Related-Transfer-Function configuration
- Sound
Controller - Controls playback and position of a spatial audio source
- Stereo
Config - Stereo Playback configuration
Enums§
- Playback
Configuration - Configure playback parameters