Skip to main content

Crate atome

Crate atome 

Source
Expand description

A real-time audio engine over cpal.

AudioEngine owns every stream and decides what reaches which device. It is given a list of inputs and a list of outputs, both described as AtomeDevices, and builds an InputClass or OutputClass for each.

§Routing

An input with no routing feeds every output. An input that names outputs feeds only those, so a talkback microphone can reach the monitors without also reaching the main mix.

§Plugins

A Plugin attaches at one of three levels, and where it attaches is what decides how much audio it hears:

Attached toHears
An input’s AtomeDevicethat input alone, before routing
An output’s AtomeDevicewhat that device plays, after mixing
AudioEngine::new directlyeverything

The shortest one to write is an internal plugin — a Rust function compiled in, needing no feature and nothing installed on the machine:

use atome::Plugin;

let quieter = Plugin::internal("-6 dB", |buffer: &mut [f32], _channels| {
    for sample in buffer {
        *sample *= 0.5;
    }
});

VST 3 and Audio Units are hosted too, each behind its own feature. See plugins for the full table.

use atome::{device::AtomeDevice, AudioEngine};
use atome::output::{OutputType, SampleRate};

let mic = AtomeDevice::default_input(OutputType::CoreAudio)
    .expect("no input device");
let speakers = AtomeDevice::default_output(OutputType::CoreAudio)
    .expect("no output device");

let engine = AudioEngine::<f32>::new(
    vec![mic],
    vec![speakers],
    SampleRate::Hz48k,
    vec![2],
    Some(512),
    vec![],
)?;

Re-exports§

pub use device::AtomeDevice;
pub use device::Direction;
pub use input::InputClass;
pub use output::OutputClass;
pub use output::SampleRate;
pub use output::SampleType;
pub use plugins::Plugin;

Modules§

device
A device plus everything atome needs to know about it.
import
Working out what an audio file actually is, and decoding it.
input
Capturing audio from a device.
output
plugins
Plugin hosting, one module per format.

Structs§

AudioEngine
The main audio engine: every stream, and the routing between them.
EngineInput
An input, its stream, and the outputs it feeds.
EngineOutput
An output and its stream.