Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94ca90db69 | ||
|
|
2bf07d0fba | ||
|
|
e661022329 | ||
|
|
f4650ece00 | ||
|
|
01cc0feda2 | ||
|
|
234dcd08d0 |
@@ -21,7 +21,7 @@ repos:
|
||||
|
||||
- id: test
|
||||
name: cargo test
|
||||
entry: cargo test --all --features hardware-tests -- --include-ignored
|
||||
entry: cargo test --all -- --include-ignored
|
||||
language: system
|
||||
pass_filenames: false
|
||||
stages: [pre-push]
|
||||
|
||||
Generated
+82
-26
@@ -19,9 +19,9 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.1"
|
||||
version = "0.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
@@ -60,6 +60,17 @@ version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "chacha20"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.45"
|
||||
@@ -79,10 +90,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.23.0"
|
||||
name = "cpufeatures"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d"
|
||||
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
@@ -90,26 +110,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.23.0"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0"
|
||||
checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"
|
||||
dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 2.0.119",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.23.0"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d"
|
||||
checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -163,6 +183,7 @@ name = "dsp_thomann"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dotenvy",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
@@ -213,6 +234,18 @@ dependencies = [
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
@@ -445,6 +478,29 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
|
||||
dependencies = [
|
||||
"chacha20",
|
||||
"getrandom",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
|
||||
|
||||
[[package]]
|
||||
name = "ref-cast"
|
||||
version = "1.0.27"
|
||||
@@ -462,7 +518,7 @@ checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.2",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -522,7 +578,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.2",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -540,9 +596,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_with"
|
||||
version = "3.22.0"
|
||||
version = "3.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee78f1fbe43ac4a0e47aadb3dbd357b69eb0d3793e948624cd03dd2750ab1c0a"
|
||||
checksum = "df9adc193c780ef8f159aee8b61e2d5801aaa555e6eb0947fe45530ec506296f"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bs58",
|
||||
@@ -561,14 +617,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_with_macros"
|
||||
version = "3.22.0"
|
||||
version = "3.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8705578779c2b6bd90d84d66eb2e206b708b1a4d7b9f17641b293545bf1c7e46"
|
||||
checksum = "3e17bbc68e28663bbbb90df47e058aa7eda4fb445b89fe70457bb94fbccf6e49"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -620,9 +676,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.2"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a207d6d6a2b7fc470b80443726053f18a2481b7e1eee970597051596567987a3"
|
||||
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -631,22 +687,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.20"
|
||||
version = "2.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
|
||||
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.20"
|
||||
version = "2.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
|
||||
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.2",
|
||||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -732,7 +788,7 @@ dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.2",
|
||||
"syn 3.0.6",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
|
||||
+3
-2
@@ -7,12 +7,13 @@ edition = "2024"
|
||||
dotenvy = "0.15"
|
||||
|
||||
[dependencies]
|
||||
thiserror = "2.0.20"
|
||||
thiserror = "2.0.21"
|
||||
strum = "0.28.0"
|
||||
strum_macros = "0.28.0"
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
serde_json = { version = "1", optional = true }
|
||||
serde_with = "3"
|
||||
serde_with = "3.24.0"
|
||||
rand = "0.10.3"
|
||||
|
||||
[lib]
|
||||
name = "dsp_thomann"
|
||||
|
||||
+67
-12
@@ -617,26 +617,81 @@ delay = delay_min + (raw / 255) × (delay_max - delay_min)
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| **Purpose** | Per-channel level + peak metering |
|
||||
| **Size** | 3 bytes per channel |
|
||||
| **Total** | 12 channels × 3 bytes = 36 bytes |
|
||||
| **Purpose** | Per-channel RMS + peak metering, with clip flags |
|
||||
| **Payload size** | 38 bytes (exactly; any other length is an error) |
|
||||
| **Layout** | 12 channels × 3 bytes = 36 bytes, followed by 2 clip-flag bytes |
|
||||
| **Channel order** | Channels 0–3 are inputs, channels 4–11 are outputs, each mapped in enum order |
|
||||
|
||||
#### Channel record (3 bytes, at offset `i = channel × 3`)
|
||||
|
||||
| Byte offset | Field | Format |
|
||||
|---|---|---|
|
||||
| 0–1 | Level | IEEE754 float16, little-endian |
|
||||
| 2 | Peak | 1-byte peak value (format not specified in source) |
|
||||
| `i + 0` | RMS low byte | Low byte of the RMS float16 |
|
||||
| `i + 1` | Shared high byte | High byte of **both** the RMS and Peak float16s |
|
||||
| `i + 2` | Peak low byte | Low byte of the Peak float16 |
|
||||
|
||||
Both values are IEEE 754 half-precision floats (little-endian pairs). The peak is not a separate 1-byte value: it reuses byte `i + 1` as its high byte, so its byte order is reversed relative to the offset order.
|
||||
|
||||
**Encoding (value → raw):**
|
||||
```text
|
||||
level_bytes = float16_encode(level) // 2 bytes, little-endian
|
||||
peak_byte = peak_encode(peak) // format undefined — see note below
|
||||
raw = level_bytes + peak_byte
|
||||
rms_raw = float16_decode(lo = payload[i], hi = payload[i + 1])
|
||||
peak_raw = float16_decode(lo = payload[i + 2], hi = payload[i + 1])
|
||||
```
|
||||
|
||||
**Decoding (raw → value):**
|
||||
If a float16 fails to decode, the raw value defaults to `0.0`, which converts to `MIN_DB` (-60 dB).
|
||||
|
||||
#### Clip flags (bytes 36–37)
|
||||
|
||||
| Channel index | Flag location |
|
||||
|---|---|
|
||||
| 0–3 | `payload[36]`, bit `index` |
|
||||
| 4–11 | `payload[37]`, bit `index - 4` |
|
||||
|
||||
```text
|
||||
level = float16_decode(raw[0:2]) // little-endian
|
||||
peak = peak_decode(raw[2]) // format undefined — see note below
|
||||
clip = (flags_byte & (1 << bit)) != 0
|
||||
```
|
||||
|
||||
#### Raw → dB conversion
|
||||
|
||||
Raw values are converted with a piecewise-linear curve, then clamped.
|
||||
|
||||
| Constant | Value | Meaning |
|
||||
|---|---|---|
|
||||
| `X0` | -25.0 dB | Breakpoint |
|
||||
| `Y0` | 1.0 | Raw value at the breakpoint |
|
||||
| `K1` | 0.0104 | Raw units per dB below the breakpoint (`raw < Y0`) |
|
||||
| `K2` | 0.0208 | Raw units per dB above the breakpoint (`raw >= Y0`) |
|
||||
| `MIN_DB` | -60.0 dB | Lower clamp |
|
||||
| `MAX_DB` | 12.0 dB | Upper clamp |
|
||||
|
||||
**Decoding (raw → dB):**
|
||||
```text
|
||||
if raw < Y0: db = X0 + (raw - Y0) / K1
|
||||
else: db = X0 + (raw - Y0) / K2
|
||||
db = clamp(db, MIN_DB, MAX_DB)
|
||||
```
|
||||
|
||||
**Encoding (dB → raw):** the inverse of the above. Values outside the clamp range are not recoverable.
|
||||
```text
|
||||
db = clamp(db, MIN_DB, MAX_DB)
|
||||
if db < X0: raw = Y0 + (db - X0) * K1
|
||||
else: raw = Y0 + (db - X0) * K2
|
||||
```
|
||||
|
||||
#### Full decode
|
||||
|
||||
```text
|
||||
require len(payload) == 38
|
||||
|
||||
for index in 0..11:
|
||||
i = index * 3
|
||||
rms_db = raw_to_db(float16_decode(payload[i], payload[i + 1]))
|
||||
peak_db = raw_to_db(float16_decode(payload[i + 2], payload[i + 1]))
|
||||
clip = index < 4 ? payload[36] bit index
|
||||
: payload[37] bit (index - 4)
|
||||
meter[index] = { rms: rms_db, peak: peak_db, clip }
|
||||
|
||||
inputs = meter[0..3] → InputChannel enum order
|
||||
outputs = meter[4..11] → OutputChannel enum order
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use rand::RngExt;
|
||||
use std::collections::HashMap;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use super::types::{
|
||||
use crate::dsp408::types::ConnectionStatus;
|
||||
use crate::dsp408::types::{
|
||||
Compressor, Crossover, CrossoverFilter, CrossoverFilters, DSPConfigState, DSPState, DelayUnit,
|
||||
DeviceFlags, DiscreteFrequency, Gate, GraphicEQ, InputChannel, InputChannelState, InputMeters,
|
||||
InputSource, InputType, Limiter, MatrixRoutes, Meter, OutputChannel, OutputChannelState,
|
||||
@@ -17,11 +19,13 @@ pub fn default_dsp_state() -> DSPState {
|
||||
DSPState {
|
||||
name: "Default".to_string(),
|
||||
|
||||
flags: DeviceFlags { is_locked: false },
|
||||
flags: DeviceFlags { is_locked: true },
|
||||
|
||||
presets: default_preset_bank(),
|
||||
|
||||
current_config: default_config(),
|
||||
|
||||
connection: ConnectionStatus::Disconnected,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,3 +302,32 @@ fn default_meter() -> Meter {
|
||||
clip: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn random_meter() -> Meter {
|
||||
let mut rng = rand::rng();
|
||||
|
||||
let rms = rng.random_range(-60.0..=0.0);
|
||||
let peak = (rms + rng.random_range(0.0..=12.0) as f32).min(12.0);
|
||||
|
||||
Meter {
|
||||
rms,
|
||||
peak,
|
||||
clip: peak > 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn random_input_meters() -> InputMeters {
|
||||
InputMeters {
|
||||
meters: InputChannel::iter()
|
||||
.map(|channel| (channel, random_meter()))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn random_output_meters() -> OutputMeters {
|
||||
OutputMeters {
|
||||
meters: OutputChannel::iter()
|
||||
.map(|channel| (channel, random_meter()))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
+148
-177
@@ -10,15 +10,17 @@ use std::{
|
||||
use crate::{
|
||||
common::errors::DSPError,
|
||||
dsp408::{
|
||||
default::{default_input_meters, default_output_meters},
|
||||
default_dsp_state,
|
||||
client::default::{
|
||||
default_dsp_state, default_input_meters, default_output_meters, random_input_meters,
|
||||
random_output_meters,
|
||||
},
|
||||
mapper::{
|
||||
self,
|
||||
constants::{CONFIG_CHUNK_INDEX_MAX, PRESET_INDEX_MAX, delay_range},
|
||||
response::map_response,
|
||||
},
|
||||
protocol::{commands, config::decode_config, frame::extract_frame},
|
||||
types,
|
||||
types::{self, ConnectionStatus::Disconnected, DSPMode},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -32,9 +34,9 @@ fn instances() -> &'static Mutex<HashMap<(IpAddr, u8), ()>> {
|
||||
}
|
||||
|
||||
pub struct DSP408 {
|
||||
mode: types::DSPMode,
|
||||
connection: types::DeviceConnection,
|
||||
socket: Arc<Mutex<Option<TcpStream>>>,
|
||||
mode: DSPMode,
|
||||
state: types::DSPState,
|
||||
input_meters: types::InputMeters,
|
||||
output_meters: types::OutputMeters,
|
||||
@@ -57,7 +59,7 @@ impl DSP408 {
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
mode: types::DSPMode::Disconnected,
|
||||
mode: types::DSPMode::Normal,
|
||||
|
||||
connection: types::DeviceConnection {
|
||||
host,
|
||||
@@ -140,7 +142,7 @@ impl DSP408 {
|
||||
}
|
||||
|
||||
pub fn connected(&self) -> bool {
|
||||
self.mode == types::DSPMode::Connected
|
||||
self.state.connection == types::ConnectionStatus::Connected
|
||||
}
|
||||
|
||||
pub fn demo(&self) -> bool {
|
||||
@@ -185,6 +187,7 @@ impl DSP408 {
|
||||
modified: modified.modified,
|
||||
},
|
||||
current_config: state,
|
||||
connection: Disconnected,
|
||||
};
|
||||
|
||||
Ok(())
|
||||
@@ -201,10 +204,11 @@ impl DSP408 {
|
||||
// Command `0x10`
|
||||
pub fn connect(&mut self) -> Result<(), DSPError> {
|
||||
if self.mode == types::DSPMode::Demo {
|
||||
self.state.connection = types::ConnectionStatus::Connected;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if self.mode == types::DSPMode::Connected {
|
||||
if self.state.connection == types::ConnectionStatus::Connected {
|
||||
return Err(DSPError::AlreadyConnected);
|
||||
}
|
||||
|
||||
@@ -271,7 +275,7 @@ impl DSP408 {
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
self.mode = types::DSPMode::Connected;
|
||||
self.state.connection = types::ConnectionStatus::Connected;
|
||||
|
||||
instances()
|
||||
.lock()
|
||||
@@ -289,6 +293,11 @@ impl DSP408 {
|
||||
|
||||
// Command `0x11`
|
||||
pub fn disconnect(&mut self) -> Result<(), DSPError> {
|
||||
if self.mode == types::DSPMode::Demo {
|
||||
self.state.connection = types::ConnectionStatus::Disconnected;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let key = (self.connection.host, self.connection.device_id);
|
||||
|
||||
let mut socket_guard = self
|
||||
@@ -306,9 +315,7 @@ impl DSP408 {
|
||||
.map_err(|e| DSPError::MutexPoisoned(e.to_string()))?
|
||||
.remove(&key);
|
||||
|
||||
if self.mode == types::DSPMode::Connected {
|
||||
self.mode = types::DSPMode::Disconnected;
|
||||
}
|
||||
self.state.connection = types::ConnectionStatus::Disconnected;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -362,8 +369,9 @@ impl DSP408 {
|
||||
pub fn set_delay_unit(&mut self, unit: types::DelayUnit) -> Result<bool, DSPError> {
|
||||
let raw_unit = mapper::delay_unit_to_raw(unit)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_set_delay_unit(raw_unit)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -383,12 +391,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -416,8 +421,9 @@ impl DSP408 {
|
||||
pub fn recall_preset(&mut self, preset_index: usize) -> Result<bool, DSPError> {
|
||||
let raw_index = mapper::preset_index_to_raw(preset_index)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_recall(raw_index)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -439,11 +445,11 @@ impl DSP408 {
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
types::DSPMode::Demo => {
|
||||
} else if self.mode == types::DSPMode::Demo {
|
||||
self.state = default_dsp_state();
|
||||
}
|
||||
types::DSPMode::Disconnected => {
|
||||
}
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -465,8 +471,9 @@ impl DSP408 {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_store_current_configuration(raw_index)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -492,8 +499,8 @@ impl DSP408 {
|
||||
));
|
||||
}
|
||||
}
|
||||
types::DSPMode::Demo => {}
|
||||
types::DSPMode::Disconnected => {
|
||||
}
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -524,8 +531,9 @@ impl DSP408 {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_factory_reset();
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -544,16 +552,12 @@ impl DSP408 {
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
// Hardware accepted the reset.
|
||||
} else if self.mode == types::DSPMode::Demo {
|
||||
self.state = default_dsp_state();
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
self.state = default_dsp_state();
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -565,8 +569,9 @@ impl DSP408 {
|
||||
pub fn set_current_preset_name(&mut self, name: &str) -> Result<bool, DSPError> {
|
||||
let raw_name = mapper::preset_name_to_raw(name)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_store_current_preset_name(&raw_name)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -596,10 +601,8 @@ impl DSP408 {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware operations.
|
||||
}
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -704,8 +707,9 @@ impl DSP408 {
|
||||
) -> Result<bool, DSPError> {
|
||||
let (raw_channel_1, raw_channel_2) = mapper::copy_channel_to_raw(channel_1, channel_2)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_copy_channel(raw_channel_1, raw_channel_2)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -725,12 +729,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -759,8 +760,9 @@ impl DSP408 {
|
||||
pub fn unlock_device(&mut self, password: &str) -> Result<bool, DSPError> {
|
||||
let raw_password = mapper::password_to_raw(password)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_unlock_device(&raw_password)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -780,12 +782,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// Emulate successful unlock locally.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -799,8 +798,9 @@ impl DSP408 {
|
||||
pub fn lock_device(&mut self, password: &str) -> Result<bool, DSPError> {
|
||||
let raw_password = mapper::password_to_raw(password)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_lock_device(&raw_password)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -820,18 +820,17 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// Emulate locking locally.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
|
||||
self.state_mut().flags.is_locked = true;
|
||||
|
||||
self.disconnect()?;
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
@@ -852,8 +851,9 @@ impl DSP408 {
|
||||
let raw_knee = mapper::knee_db_to_raw(knee)?;
|
||||
let raw_threshold = mapper::threshold_db_to_raw(threshold)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_set_compressor(
|
||||
raw_channel,
|
||||
raw_ratio,
|
||||
@@ -880,12 +880,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -916,8 +913,9 @@ impl DSP408 {
|
||||
let raw_freq = mapper::frequency_hz_to_raw(freq)?;
|
||||
let raw_filter = mapper::crossover_filter_to_raw(filter_type)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_low_pass(raw_channel, raw_freq, raw_filter)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -937,12 +935,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -987,8 +982,9 @@ impl DSP408 {
|
||||
let raw_freq = mapper::frequency_hz_to_raw(freq)?;
|
||||
let raw_filter = mapper::crossover_filter_to_raw(filter_type)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_high_pass(raw_channel, raw_freq, raw_filter)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1008,12 +1004,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1066,8 +1059,9 @@ impl DSP408 {
|
||||
let raw_q = mapper::peq_q_to_raw(q, filter_type)?;
|
||||
let raw_filter = mapper::peq_filter_to_raw(filter_type)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_peq_band(
|
||||
raw_channel,
|
||||
raw_band,
|
||||
@@ -1095,12 +1089,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1144,8 +1135,9 @@ impl DSP408 {
|
||||
let raw_channel = mapper::channel_to_raw(channel)?;
|
||||
let raw_db = mapper::gain_db_to_raw(db)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_gain(raw_channel, raw_db)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1165,12 +1157,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1194,8 +1183,9 @@ impl DSP408 {
|
||||
pub fn set_mute(&mut self, channel: types::Channel, muted: bool) -> Result<bool, DSPError> {
|
||||
let raw_channel = mapper::channel_to_raw(channel)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_mute(raw_channel, muted as u8)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1215,12 +1205,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1248,8 +1235,9 @@ impl DSP408 {
|
||||
) -> Result<bool, DSPError> {
|
||||
let raw_channel = mapper::channel_to_raw(channel)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_inverted_gain(raw_channel, inverted as u8)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1269,12 +1257,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1304,8 +1289,9 @@ impl DSP408 {
|
||||
let raw_channel = mapper::channel_to_raw(channel)?;
|
||||
let raw_delay = mapper::delay_to_raw(delay, unit)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_set_delay(raw_channel, raw_delay)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1325,12 +1311,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1356,8 +1339,9 @@ impl DSP408 {
|
||||
let raw_source = mapper::input_source_to_raw(input_source.r#type)?;
|
||||
let raw_frequency = mapper::frequency_value_to_raw(input_source.frequency)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_set_input_source(raw_source, raw_frequency)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1377,12 +1361,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1404,8 +1385,9 @@ impl DSP408 {
|
||||
let raw_output = mapper::output_channel_to_raw(output)?;
|
||||
let raw_inputs = mapper::matrix_to_raw(&inputs)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_matrix_routing(raw_output, raw_inputs)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1425,12 +1407,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1466,8 +1445,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
// Link source
|
||||
let request = commands::build_link_channel(raw_source, bitmask)?;
|
||||
|
||||
@@ -1520,12 +1500,9 @@ impl DSP408 {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// Copy already applied above; nothing else to reconcile.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1589,8 +1566,9 @@ impl DSP408 {
|
||||
) -> Result<bool, DSPError> {
|
||||
let raw_channel = mapper::channel_to_raw(channel)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_bypass_peq(raw_channel, bypass as u8)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1610,12 +1588,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1648,8 +1623,9 @@ impl DSP408 {
|
||||
let raw_channel = mapper::channel_to_raw(channel)?;
|
||||
let raw_name = mapper::channel_name_to_raw(name)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_store_channel_name(raw_channel, &raw_name)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1669,12 +1645,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1711,8 +1684,9 @@ impl DSP408 {
|
||||
let raw_hold = mapper::hold_ms_to_raw(hold)?;
|
||||
let raw_release = mapper::release_ms_to_raw(release)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_set_gate(
|
||||
raw_channel,
|
||||
raw_threshold,
|
||||
@@ -1738,12 +1712,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1774,8 +1745,9 @@ impl DSP408 {
|
||||
let raw_attack = mapper::attack_ms_to_raw(attack)?;
|
||||
let raw_release = mapper::release_ms_to_raw(release)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_set_limiter(
|
||||
raw_channel,
|
||||
raw_threshold,
|
||||
@@ -1800,12 +1772,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1826,8 +1795,15 @@ impl DSP408 {
|
||||
pub fn get_meter_levels(
|
||||
&mut self,
|
||||
) -> Result<(types::InputMeters, types::OutputMeters), DSPError> {
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Demo {
|
||||
self.input_meters = random_input_meters();
|
||||
self.output_meters = random_output_meters();
|
||||
|
||||
return Ok((self.input_meters.clone(), self.output_meters.clone()));
|
||||
}
|
||||
|
||||
let request = commands::build_get_meter_levels();
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1846,12 +1822,7 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// Return the locally simulated meter values.
|
||||
Ok((self.input_meters.clone(), self.output_meters.clone()))
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => Err(DSPError::NotConnected),
|
||||
types::ConnectionStatus::Disconnected => Err(DSPError::NotConnected),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1866,10 +1837,14 @@ impl DSP408 {
|
||||
let raw_output_channel = mapper::output_channel_to_raw(output_channel)?;
|
||||
let raw_gain = mapper::matrix_gain_db_to_raw(gain)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
let request =
|
||||
commands::build_matrix_gain(raw_input_channel, raw_output_channel, raw_gain)?;
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_matrix_gain(
|
||||
raw_input_channel,
|
||||
raw_output_channel,
|
||||
raw_gain,
|
||||
)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
|
||||
@@ -1888,12 +1863,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1919,10 +1891,14 @@ impl DSP408 {
|
||||
let raw_frequency_band = mapper::frequency_value_to_raw(frequency_band)?;
|
||||
let raw_gain = mapper::eq_gain_db_to_raw(gain)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
let request =
|
||||
commands::build_set_geq_band(raw_input_channel, raw_frequency_band, raw_gain)?;
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_set_geq_band(
|
||||
raw_input_channel,
|
||||
raw_frequency_band,
|
||||
raw_gain,
|
||||
)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
|
||||
@@ -1941,12 +1917,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
@@ -1972,8 +1945,9 @@ impl DSP408 {
|
||||
) -> Result<bool, DSPError> {
|
||||
let raw_input_channel = mapper::input_channel_to_raw(input_channel)?;
|
||||
|
||||
match self.mode {
|
||||
types::DSPMode::Connected => {
|
||||
match self.state.connection {
|
||||
types::ConnectionStatus::Connected => {
|
||||
if self.mode == types::DSPMode::Normal {
|
||||
let request = commands::build_set_geq_bypass(raw_input_channel, bypass as u8)?;
|
||||
|
||||
let resp = self.send_recv(&request)?;
|
||||
@@ -1993,12 +1967,9 @@ impl DSP408 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
types::DSPMode::Demo => {
|
||||
// No hardware request.
|
||||
}
|
||||
|
||||
types::DSPMode::Disconnected => {
|
||||
types::ConnectionStatus::Disconnected => {
|
||||
return Err(DSPError::NotConnected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
mod default;
|
||||
mod dsp408;
|
||||
|
||||
pub use dsp408::DSP408;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
mod client;
|
||||
mod default;
|
||||
mod mapper;
|
||||
mod protocol;
|
||||
|
||||
pub mod types;
|
||||
|
||||
pub use client::DSP408;
|
||||
pub(crate) use default::default_dsp_state;
|
||||
|
||||
@@ -297,9 +297,7 @@ pub fn decode_config(payload: &[u8]) -> Result<types::DSPConfigState, DSPError>
|
||||
for (index, inp) in input_channels.iter_mut().enumerate() {
|
||||
let bypass = input_peq_bitmap & (1 << index) != 0;
|
||||
|
||||
for peq in inp.peq_chain.bands.values_mut() {
|
||||
peq.bypass = bypass;
|
||||
}
|
||||
inp.peq_chain.bypass = bypass;
|
||||
}
|
||||
|
||||
let output_peq_bitmap = r.read_u16()?;
|
||||
@@ -307,9 +305,7 @@ pub fn decode_config(payload: &[u8]) -> Result<types::DSPConfigState, DSPError>
|
||||
for (index, out) in output_channels.iter_mut().enumerate() {
|
||||
let bypass = output_peq_bitmap & (1 << index) != 0;
|
||||
|
||||
for peq in out.peq_chain.bands.values_mut() {
|
||||
peq.bypass = bypass;
|
||||
}
|
||||
out.peq_chain.bypass = bypass;
|
||||
}
|
||||
|
||||
let bitmap = r.read_u16()?;
|
||||
|
||||
+15
-8
@@ -398,6 +398,20 @@ impl DSPConfigState {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum DSPMode {
|
||||
Demo,
|
||||
Normal,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ConnectionStatus {
|
||||
Connected,
|
||||
Disconnected,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DSPState {
|
||||
@@ -405,14 +419,7 @@ pub struct DSPState {
|
||||
pub(crate) flags: DeviceFlags,
|
||||
pub(crate) presets: PresetBank,
|
||||
pub(crate) current_config: DSPConfigState,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum DSPMode {
|
||||
Demo,
|
||||
Disconnected,
|
||||
Connected,
|
||||
pub(crate) connection: ConnectionStatus,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||
|
||||
+11
-13
@@ -2,8 +2,6 @@ use std::net::IpAddr;
|
||||
use std::str::FromStr;
|
||||
|
||||
use dsp_thomann::dsp408::DSP408;
|
||||
use dsp_thomann::dsp408::types;
|
||||
use dsp_thomann::dsp408::types::InputChannel::InA;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let host = IpAddr::from_str("192.168.49.30")?;
|
||||
@@ -25,18 +23,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// dsp.set_mute(types::Channel::Input(types::InputChannel::InA), true)?;
|
||||
|
||||
let r = dsp.set_peq_band(
|
||||
types::Channel::Input(InA),
|
||||
types::PEQBand::B1,
|
||||
3.0,
|
||||
1400.0,
|
||||
2.1,
|
||||
types::PEQFilter::LowShelf,
|
||||
false,
|
||||
)?;
|
||||
dbg!(r);
|
||||
// let r = dsp.set_peq_band(
|
||||
// types::Channel::Input(InA),
|
||||
// types::PEQBand::B1,
|
||||
// 3.0,
|
||||
// 1400.0,
|
||||
// 2.1,
|
||||
// types::PEQFilter::LowShelf,
|
||||
// false,
|
||||
// )?;
|
||||
// dbg!(r);
|
||||
|
||||
// dbg!(dsp.state()?);
|
||||
dbg!(&dsp.state());
|
||||
|
||||
// let s = &dsp.state()?.current_config.input_states[&InputChannel::InA].peq_chain;
|
||||
// dbg!(s)
|
||||
|
||||
Reference in New Issue
Block a user