basic/
basic.rs

1extern crate alto;
2
3use alto::{Alto, AltoResult};
4
5fn run() -> AltoResult<()> {
6    let alto = Alto::load_default()?;
7
8    for s in alto.enumerate_outputs() {
9        println!("Found device: {}", s.to_str().unwrap());
10    }
11
12    let device = alto.open(None)?; // Opens the default audio device
13    let context = device.new_context(None)?; // Creates a default context
14
15    // Configure listener
16    context.set_position([1.0, 4.0, 5.0])?;
17    context.set_velocity([2.5, 0.0, 0.0])?;
18    context.set_orientation(([0.0, 0.0, 1.0], [0.0, 1.0, 0.0]))?;
19
20    let _source = context.new_static_source()?;
21
22    // Now you can load your samples and store them in a buffer with
23    // `context.new_buffer(samples, frequency)`;
24
25    Ok(())
26}
27
28fn main() {
29    use std::process::exit;
30
31    if let Err(e) = run() {
32        println!("Failed to run basic example: {}", e);
33        exit(1);
34    }
35}