[][src]Crate minidsp

This crate provides a high level API for accessing and configuring a MiniDSP device. To get started, start by instantiating the right transport. If the device is locally connected via USB, use transport::hid::HidTransport. If using the WI-DG or connecting to an instance of this program running the server component, see transport::net::NetTransport.

use minidsp::{MiniDSP, device::DEVICE_2X4HD, transport, Channel, Gain};
use anyhow::Result;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<()> {
    let hid_api = transport::hid::initialize_api()?;
    // Find a locally connected minidsp using usb hid, with the default vendor and product id.
    let transport =  Arc::new(transport::hid::HidTransport::with_product_id(&hid_api, 0x2752, 0x0011)?);

    // Instantiate a 2x4HD handler for this device.
    let dsp = MiniDSP::new(transport, &DEVICE_2X4HD);
     
    let status = dsp.get_master_status().await?;
    println!("Master volume: {:.1}", status.volume.0);

    // Activate a different configuration
    dsp.set_config(2).await?;

    // Set the input gain for both input channels
    for i in 0..2 {
        dsp.input(i).set_gain(Gain(-10.)).await?;
    }

    // Mute the last output channel
    dsp.output(3).set_mute(true).await?;

    Ok(())
}

Re-exports

pub use crate::commands::Gain;
pub use source::Source;

Modules

commands

Commands sent to the device and their responses

device

Static device definitions

discovery

Enables discovery and advertisement of tcp servers. The packet format is compatible with the official apps.

lease

Helper module to control the minidsp's source and volume based on an RAII guard

packet

Functions for framing and unframing packets, and computing their checksums

server

TCP server compatible with the official mobile and desktop application

source

Utilities to get a mapping from the source name to the source id Most of this logic was translated from the cordova app

transport

Transport base traits for talking to devices

Structs

BiquadFilter

Helper object for controlling an on-device biquad filter

DeviceInfo

Hardware id and dsp version

Input

Input channel control

MiniDSP

High-level MiniDSP Control API

Output

Output channel control

Traits

Channel

Type Definitions

Result