#control-api #control #api #wrapper #networking #motu #avb

motu_avb_api

使用 Rust 控制 MOTU AVB 音频卡

9 个版本 (4 个重大更改)

0.5.3 2023 年 1 月 10 日
0.5.2 2023 年 1 月 10 日
0.5.1 2022 年 12 月 13 日
0.4.0 2022 年 12 月 5 日
0.1.0 2022 年 11 月 24 日

#1209 in 网页编程

每月下载 25

MIT 许可证

47KB
1K SLoC

MOTU AVB API for Rust

通过 HTTP 与 MOTU AVB 设备交互的包装器。简化了解决通道设置和获取设备实时数据的过程。目前仅提供简单的通道组包装器,混合功能即将推出。

如何

use motu_avb_api::Update;
use tokio::time::{sleep, Duration};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Find by specifying device name
    let mut d = motu_avb_api::from_name("624", None).await?;
    d.connect().await?;

    // Or discover avaliable devices on the network
    //
    // let mut d = Device::discover(Some(std::time::Duration::from_secs(3))).await?;
    // d.first().unwrap().connect().await?;

    // Lets have a look at the first input channel bank
    let channel_bank = d.input_banks()?;
    print!("{}", channel_bank.get(&0).unwrap().value());

    // Now lets change the volume of the first trimmable output

    let req = d
        .output_banks()?
        .get(&0)
        .unwrap()
        .set_channel_trim(0, -30)
        .unwrap();

    let _ = d.set(req).await;

    // You can also listen to updates!

    let mut updates = d.updates()?;
    tokio::spawn(async move {
        loop {
            let update = updates.recv().await.unwrap();

            // Only listen for updates that happened outside our application
            // If you really want every update you can listen to both internal and external
            match update {
                Update::External(k, v) => println!("update for {} : {}", k, v),
                _ => {}
            };
        }
    });

    sleep(Duration::from_secs(10)).await;
    Ok(())
}

为什么

是的,我实在不知道为什么花了这么多时间。MOTU 的人显然疯了,出于某种荒谬的原因决定重新发明 JSON... 现在这样也可以工作。个人不推荐:不要购买 MOTU 产品

依赖项

~10–26MB
~406K SLoC