nandi/jolt-nativepublic Fork 0
cfd3e3677bed92e80cfe447469a249cfdc0b1401
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Lift freeq's AV media plane out of sleek 90f8b89 · on cfd3e3677bed92e80cfe447469a249cfdc0b1401 · nandi · 19d ago
enumerate.rs · 59 lines · 1.6 KBRust Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* This example aims to produce the same behaviour
 * as the enumerate example in cpal
 * by Tom Gowan
 */

extern crate asio_sys as sys;

// This is the same data that enumerate
// is trying to find
// Basically these are stubbed versions
//
// Format that each sample has.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SampleFormat {
    // The value 0 corresponds to 0.
    I16,
    // The value 0 corresponds to 32768.
    U16,
    // The boundaries are (-1.0, 1.0).
    F32,
}
// Number of channels.
pub type ChannelCount = u16;

// The number of samples processed per second for a single channel of audio.
pub type SampleRate = u32;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Format {
    pub channels: ChannelCount,
    pub sample_rate: SampleRate,
    pub data_type: SampleFormat,
}

fn main() {
    let asio = sys::Asio::new();
    for name in asio.driver_names() {
        println!("Driver: {:?}", name);
        let driver = asio.load_driver(&name).expect("failed to load driver");
        let channels = driver
            .channels()
            .expect("failed to retrieve channel counts");
        let sample_rate = driver
            .sample_rate()
            .expect("failed to retrieve sample rate");
        let in_fmt = Format {
            channels: channels.ins as _,
            sample_rate: sample_rate as _,
            data_type: SampleFormat::F32,
        };
        let out_fmt = Format {
            channels: channels.outs as _,
            sample_rate: sample_rate as _,
            data_type: SampleFormat::F32,
        };
        println!("  Input {:?}", in_fmt);
        println!("  Output {:?}", out_fmt);
    }
}