Expand description
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::StreamTransport
.
use anyhow::Result;
use futures::StreamExt;
use minidsp::{
transport::{hid, Multiplexer},
Builder, Channel, Gain, MiniDSP,
};
#[tokio::main]
async fn main() -> Result<()> {
// Get a list of local devices
let mut builder = Builder::new();
builder.with_default_usb().unwrap();
let mut devices: Vec<_> = builder
// Probe each candidate device for its hardware id and serial number
.probe()
// Filter the list to keep the working devices
.filter_map(|x| async move { x.ok() })
.collect()
.await;
// Use the first device for further commands
let dsp = devices
.first()
.expect("no devices found")
.to_minidsp()
.expect("unable to open device");
let status = dsp.get_master_status().await?;
println!("Master volume: {:.1}", status.volume.unwrap().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
Modules
Basic biquad definition
Device discovery integrated as the builder pattern
Commands sent to the device and their responses
Static device definitions
EEPROM Addresses
Functions for framing and unframing packets, and computing their checksums
Utilities to get a mapping from the source name to the source id Most of this logic was translated from the cordova app
TCP server compatible with the official mobile and desktop application
Transport base traits for talking to devices Wraps a Stream + Sink backend into a transport
Structs
Helper object for controlling an on-device biquad filter
Hardware id and dsp version
Dialect represents the different encodings between devices
A gain between the minimum and maximum allowed values
Reference to a control having both a mute and gain setting
Input channel control
Settings applying to all outputs
High-level MiniDSP Control API
Output channel control
Enums
Traits
Types that can be read from a contiguous memory representation