feat: use new meter format

This commit is contained in:
2026-09-13 09:04:04 +02:00
parent 1e00ca3a7c
commit 9f2ace9698
11 changed files with 131 additions and 124 deletions
+18 -17
View File
@@ -397,7 +397,7 @@ dependencies = [
"semver", "semver",
"serde", "serde",
"serde_json", "serde_json",
"thiserror 2.0.19", "thiserror 2.0.20",
] ]
[[package]] [[package]]
@@ -798,9 +798,10 @@ version = "0.1.0"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"serde_with",
"strum", "strum",
"strum_macros", "strum_macros",
"thiserror 2.0.19", "thiserror 2.0.20",
] ]
[[package]] [[package]]
@@ -2004,7 +2005,7 @@ dependencies = [
"once_cell", "once_cell",
"png 0.18.1", "png 0.18.1",
"serde", "serde",
"thiserror 2.0.19", "thiserror 2.0.20",
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
@@ -2628,7 +2629,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac"
dependencies = [ dependencies = [
"getrandom 0.2.17", "getrandom 0.2.17",
"libredox", "libredox",
"thiserror 2.0.19", "thiserror 2.0.20",
] ]
[[package]] [[package]]
@@ -3338,7 +3339,7 @@ dependencies = [
"tauri-runtime", "tauri-runtime",
"tauri-runtime-wry", "tauri-runtime-wry",
"tauri-utils", "tauri-utils",
"thiserror 2.0.19", "thiserror 2.0.20",
"tokio", "tokio",
"tray-icon", "tray-icon",
"url", "url",
@@ -3389,7 +3390,7 @@ dependencies = [
"sha2", "sha2",
"syn 2.0.119", "syn 2.0.119",
"tauri-utils", "tauri-utils",
"thiserror 2.0.19", "thiserror 2.0.20",
"time", "time",
"url", "url",
"uuid", "uuid",
@@ -3442,7 +3443,7 @@ dependencies = [
"serde_json", "serde_json",
"tauri", "tauri",
"tauri-plugin", "tauri-plugin",
"thiserror 2.0.19", "thiserror 2.0.20",
"url", "url",
"windows", "windows",
"zbus", "zbus",
@@ -3466,7 +3467,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"tauri-utils", "tauri-utils",
"thiserror 2.0.19", "thiserror 2.0.20",
"url", "url",
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
@@ -3529,7 +3530,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_with", "serde_with",
"swift-rs", "swift-rs",
"thiserror 2.0.19", "thiserror 2.0.20",
"toml 1.1.3+spec-1.1.0", "toml 1.1.3+spec-1.1.0",
"url", "url",
"urlpattern", "urlpattern",
@@ -3581,11 +3582,11 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.19" version = "2.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9" checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
dependencies = [ dependencies = [
"thiserror-impl 2.0.19", "thiserror-impl 2.0.20",
] ]
[[package]] [[package]]
@@ -3601,9 +3602,9 @@ dependencies = [
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "2.0.19" version = "2.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd" checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -3918,7 +3919,7 @@ dependencies = [
"once_cell", "once_cell",
"png 0.18.1", "png 0.18.1",
"serde", "serde",
"thiserror 2.0.19", "thiserror 2.0.20",
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
@@ -4278,7 +4279,7 @@ version = "0.38.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "381336cfffd772377d291702245447a5251a2ffa5bad679c99e61bc48bacbf9c" checksum = "381336cfffd772377d291702245447a5251a2ffa5bad679c99e61bc48bacbf9c"
dependencies = [ dependencies = [
"thiserror 2.0.19", "thiserror 2.0.20",
"windows", "windows",
"windows-core 0.61.2", "windows-core 0.61.2",
] ]
@@ -4713,7 +4714,7 @@ dependencies = [
"sha2", "sha2",
"soup3", "soup3",
"tao-macros", "tao-macros",
"thiserror 2.0.19", "thiserror 2.0.20",
"url", "url",
"webkit2gtk", "webkit2gtk",
"webkit2gtk-sys", "webkit2gtk-sys",
+5 -3
View File
@@ -44,7 +44,8 @@ impl AppState {
#[derive(serde::Serialize)] #[derive(serde::Serialize)]
pub struct DSP408Snapshot { pub struct DSP408Snapshot {
pub state: types::DSPState, pub state: types::DSPState,
pub meters: types::Meters, pub input_meters: types::InputMeters,
pub output_meters: types::OutputMeters,
pub mode: types::DSPMode, pub mode: types::DSPMode,
} }
@@ -101,7 +102,8 @@ pub async fn get_dsp_snapshot(
state.with_device_mut(id, |device| { state.with_device_mut(id, |device| {
Ok(DSP408Snapshot { Ok(DSP408Snapshot {
state: device.dsp.state().clone(), state: device.dsp.state().clone(),
meters: device.dsp.meters().clone(), input_meters: device.dsp.input_meters().clone(),
output_meters: device.dsp.output_meters().clone(),
mode: device.dsp.mode(), mode: device.dsp.mode(),
}) })
}) })
@@ -202,7 +204,7 @@ pub async fn recall_preset(
pub async fn get_meter_levels( pub async fn get_meter_levels(
state: State<'_, AppState>, state: State<'_, AppState>,
id: u64, id: u64,
) -> Result<dsp_thomann::dsp408::types::Meters, String> { ) -> Result<(types::InputMeters, types::OutputMeters), String> {
state.with_device_mut(id, |device| { state.with_device_mut(id, |device| {
device.dsp.get_meter_levels().map_err(|e| e.to_string()) device.dsp.get_meter_levels().map_err(|e| e.to_string())
}) })
@@ -18,15 +18,14 @@
width: 100%; width: 100%;
font-family: var(--font-mono); font-family: var(--font-mono);
font-size: 3cqh; font-size: var(--font--sm);
font-weight: var(--font-weight-normal); font-weight: var(--font-weight-normal);
text-align: center; text-align: left;
color: var(--accent-brand); color: var(--accent-brand);
background: transparent; background: transparent;
border: none; border: none;
/* padding: 0.5ch; */
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
@@ -47,11 +46,12 @@
height: 100%; height: 100%;
box-sizing: border-box; box-sizing: border-box;
padding-right: 1%;
} }
.choice-stepper__arrow-btn { .choice-stepper__arrow-btn {
width: 3cqh; height: 50%;
height: 3cqh;
min-width: 0; min-width: 0;
min-height: 0; min-height: 0;
@@ -61,13 +61,11 @@
justify-content: center; justify-content: center;
padding: 0; padding: 0;
padding-top: 0.2cqh;
margin: 0;
color: var(--accent-brand); color: var(--accent-brand);
background: transparent; background: transparent;
border: none; border: none;
border-radius: 0.75cqh; border-radius: var(--radius-md);
cursor: pointer; cursor: pointer;
} }
+2 -1
View File
@@ -35,13 +35,14 @@
justify-content: center; justify-content: center;
flex: 0 0 auto; flex: 0 0 auto;
gap: var(--space-1);
padding: var(--space-1); padding: var(--space-1);
height: var(--header-height); height: var(--header-height);
} }
.sidebar-rail--expanded .sidebar-header { .sidebar-rail--expanded .sidebar-header {
justify-content: space-between; justify-content: space-between;
padding-inline: var(--space-3); padding-left: var(--space-3);
} }
.sidebar-toggle { .sidebar-toggle {
@@ -8,67 +8,7 @@ import MeterBar from '../../../../components/MeterBar/MeterBar';
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import ChoiceStepper from '../../../../components/ChoiceStepper/ChoiceStepper'; import ChoiceStepper from '../../../../components/ChoiceStepper/ChoiceStepper';
import './CompressorSection.css'; import './CompressorSection.css';
import { RATIO_ORDER, RATIO_LABEL, RATIO_NUMERIC, KNEE_VALUES } from '../../constants';
// Enum order defines stepper order (1:1 -> Limit).
const RATIO_ORDER: Ratio[] = [
Ratio.Ratio1_1,
Ratio.Ratio1_1_1,
Ratio.Ratio1_1_3,
Ratio.Ratio1_1_5,
Ratio.Ratio1_1_7,
Ratio.Ratio1_2,
Ratio.Ratio1_2_5,
Ratio.Ratio1_3,
Ratio.Ratio1_3_5,
Ratio.Ratio1_4,
Ratio.Ratio1_5,
Ratio.Ratio1_6,
Ratio.Ratio1_8,
Ratio.Ratio1_10,
Ratio.Ratio1_20,
Ratio.Limit,
];
const RATIO_LABEL: Record<Ratio, string> = {
[Ratio.Ratio1_1]: '1:1',
[Ratio.Ratio1_1_1]: '1.1:1',
[Ratio.Ratio1_1_3]: '1.3:1',
[Ratio.Ratio1_1_5]: '1.5:1',
[Ratio.Ratio1_1_7]: '1.7:1',
[Ratio.Ratio1_2]: '2:1',
[Ratio.Ratio1_2_5]: '2.5:1',
[Ratio.Ratio1_3]: '3:1',
[Ratio.Ratio1_3_5]: '3.5:1',
[Ratio.Ratio1_4]: '4:1',
[Ratio.Ratio1_5]: '5:1',
[Ratio.Ratio1_6]: '6:1',
[Ratio.Ratio1_8]: '8:1',
[Ratio.Ratio1_10]: '10:1',
[Ratio.Ratio1_20]: '20:1',
[Ratio.Limit]: 'Limit',
};
// Numeric ratio used only for drawing the transfer curve; Limit ~= brickwall.
const RATIO_NUMERIC: Record<Ratio, number> = {
[Ratio.Ratio1_1]: 1,
[Ratio.Ratio1_1_1]: 1.1,
[Ratio.Ratio1_1_3]: 1.3,
[Ratio.Ratio1_1_5]: 1.5,
[Ratio.Ratio1_1_7]: 1.7,
[Ratio.Ratio1_2]: 2,
[Ratio.Ratio1_2_5]: 2.5,
[Ratio.Ratio1_3]: 3,
[Ratio.Ratio1_3_5]: 3.5,
[Ratio.Ratio1_4]: 4,
[Ratio.Ratio1_5]: 5,
[Ratio.Ratio1_6]: 6,
[Ratio.Ratio1_8]: 8,
[Ratio.Ratio1_10]: 10,
[Ratio.Ratio1_20]: 20,
[Ratio.Limit]: 1000,
};
const KNEE_VALUES = Array.from({ length: 13 }, (_, i) => i); // 0..12 dB, integer steps
const COMPRESSOR_SLIDER_PARAMS = [ const COMPRESSOR_SLIDER_PARAMS = [
{ key: 'threshold', label: 'Threshold', min: -90, max: 20, step: 0.5, unit: ' dB' }, { key: 'threshold', label: 'Threshold', min: -90, max: 20, step: 0.5, unit: ' dB' },
@@ -76,19 +16,6 @@ const COMPRESSOR_SLIDER_PARAMS = [
{ key: 'release', label: 'Release', min: 10, max: 3000, step: 1, unit: ' ms' }, { key: 'release', label: 'Release', min: 10, max: 3000, step: 1, unit: ' ms' },
] as const; ] as const;
// ASSUMPTION: output meter indices follow the 4 input channels (0-3), i.e.
// Out1 -> 4, Out2 -> 5, etc. Adjust to match dsp.meters.channels ordering.
const OUTPUT_METER_INDEX: Record<OutputChannel, number> = {
[OutputChannel.Out1]: 4,
[OutputChannel.Out2]: 5,
[OutputChannel.Out3]: 6,
[OutputChannel.Out4]: 7,
[OutputChannel.Out5]: 8,
[OutputChannel.Out6]: 9,
[OutputChannel.Out7]: 10,
[OutputChannel.Out8]: 11,
} as const;
type CompressorParamKey = 'ratio' | 'attack' | 'release' | 'knee' | 'threshold'; type CompressorParamKey = 'ratio' | 'attack' | 'release' | 'knee' | 'threshold';
type CompressorValues = { type CompressorValues = {
@@ -349,10 +276,13 @@ function CompressorSection({ dsp, set_compressor }: { dsp: DSP; set_compressor:
<div className="compressor-graph__meters"> <div className="compressor-graph__meters">
{outputs.map((output) => { {outputs.map((output) => {
const outputState = dsp.state.current_config.output_states[output]; const outputState = dsp.state.current_config.output_states[output];
const idx = OUTPUT_METER_INDEX[output];
return ( return (
<MeterBar key={output} label={outputState.name} meter={dsp.meters.channels[idx]} /> <MeterBar
key={output}
label={outputState.name}
meter={dsp.output_meters.meters[output]}
/>
); );
})} })}
</div> </div>
@@ -15,13 +15,6 @@ const GATE_PARAMS = [
{ key: 'release', label: 'Release', min: 10, max: 3000, step: 1, unit: ' ms' }, { key: 'release', label: 'Release', min: 10, max: 3000, step: 1, unit: ' ms' },
] as const; ] as const;
const INPUT_METER_INDEX: Record<InputChannel, number> = {
[InputChannel.InA]: 0,
[InputChannel.InB]: 1,
[InputChannel.InC]: 2,
[InputChannel.InD]: 3,
} as const;
type GateParamKey = (typeof GATE_PARAMS)[number]['key']; type GateParamKey = (typeof GATE_PARAMS)[number]['key'];
type GateValues = { type GateValues = {
@@ -185,9 +178,14 @@ function GateSection({ dsp, set_gate }: { dsp: DSP; set_gate: SetGateFn }) {
<div className="gate-graph__meters"> <div className="gate-graph__meters">
{inputs.map((input) => { {inputs.map((input) => {
const inputState = dsp.state.current_config.input_states[input]; const inputState = dsp.state.current_config.input_states[input];
const idx = INPUT_METER_INDEX[input];
const meter = dsp.meters.channels[idx]; return (
return <MeterBar key={input} label={inputState.name} meter={meter} />; <MeterBar
key={input}
label={inputState.name}
meter={dsp.input_meters.meters[input]}
/>
);
})} })}
</div> </div>
</div> </div>
+62
View File
@@ -6,6 +6,7 @@ import {
PEQBand, PEQBand,
PEQFilter, PEQFilter,
DelayUnit, DelayUnit,
Ratio,
} from './types'; } from './types';
export const INPUT_ORDER: InputChannel[] = [ export const INPUT_ORDER: InputChannel[] = [
@@ -101,6 +102,67 @@ export const GEQ_GAIN_MAX = 12;
export const GEQ_GAIN_STEP = 0.1; export const GEQ_GAIN_STEP = 0.1;
export const GEQ_CURVE_Q = 8.65 * 0.5; export const GEQ_CURVE_Q = 8.65 * 0.5;
// ------ Compressor constants ------
export const RATIO_ORDER: Ratio[] = [
Ratio.Ratio1_1,
Ratio.Ratio1_1_1,
Ratio.Ratio1_1_3,
Ratio.Ratio1_1_5,
Ratio.Ratio1_1_7,
Ratio.Ratio1_2,
Ratio.Ratio1_2_5,
Ratio.Ratio1_3,
Ratio.Ratio1_3_5,
Ratio.Ratio1_4,
Ratio.Ratio1_5,
Ratio.Ratio1_6,
Ratio.Ratio1_8,
Ratio.Ratio1_10,
Ratio.Ratio1_20,
Ratio.Limit,
];
export const RATIO_LABEL: Record<Ratio, string> = {
[Ratio.Ratio1_1]: '1:1',
[Ratio.Ratio1_1_1]: '1.1:1',
[Ratio.Ratio1_1_3]: '1.3:1',
[Ratio.Ratio1_1_5]: '1.5:1',
[Ratio.Ratio1_1_7]: '1.7:1',
[Ratio.Ratio1_2]: '2:1',
[Ratio.Ratio1_2_5]: '2.5:1',
[Ratio.Ratio1_3]: '3:1',
[Ratio.Ratio1_3_5]: '3.5:1',
[Ratio.Ratio1_4]: '4:1',
[Ratio.Ratio1_5]: '5:1',
[Ratio.Ratio1_6]: '6:1',
[Ratio.Ratio1_8]: '8:1',
[Ratio.Ratio1_10]: '10:1',
[Ratio.Ratio1_20]: '20:1',
[Ratio.Limit]: 'Limit',
};
export const RATIO_NUMERIC: Record<Ratio, number> = {
[Ratio.Ratio1_1]: 1,
[Ratio.Ratio1_1_1]: 1.1,
[Ratio.Ratio1_1_3]: 1.3,
[Ratio.Ratio1_1_5]: 1.5,
[Ratio.Ratio1_1_7]: 1.7,
[Ratio.Ratio1_2]: 2,
[Ratio.Ratio1_2_5]: 2.5,
[Ratio.Ratio1_3]: 3,
[Ratio.Ratio1_3_5]: 3.5,
[Ratio.Ratio1_4]: 4,
[Ratio.Ratio1_5]: 5,
[Ratio.Ratio1_6]: 6,
[Ratio.Ratio1_8]: 8,
[Ratio.Ratio1_10]: 10,
[Ratio.Ratio1_20]: 20,
[Ratio.Limit]: 1000,
};
export const KNEE_VALUES = Array.from({ length: 13 }, (_, i) => i); // 0..12 dB, integer steps
// ------ Filter constants ------ // ------ Filter constants ------
export const CROSSOVER_FILTER_LABEL: { value: CrossoverFilter; label: string }[] = [ export const CROSSOVER_FILTER_LABEL: { value: CrossoverFilter; label: string }[] = [
+7 -3
View File
@@ -34,14 +34,17 @@ function pollIntervalFor(id: number): number {
async function poll(dsp: DSP408, setDsps: SetDsps) { async function poll(dsp: DSP408, setDsps: SetDsps) {
try { try {
const meters = await invoke<DSP408['meters']>('get_meter_levels', { id: dsp.id }); const [input_meters, output_meters] = await invoke<
[DSP408['input_meters'], DSP408['output_meters']]
>('get_meter_levels', { id: dsp.id });
updateDSP(setDsps, dsp.id, (d) => updateDSP(setDsps, dsp.id, (d) =>
d.pollingPaused d.pollingPaused
? d ? d
: ({ : ({
...d, ...d,
meters, input_meters,
output_meters,
} as DSP408) } as DSP408)
); );
} catch { } catch {
@@ -118,7 +121,8 @@ export async function create(params: {
status: 'disconnected', status: 'disconnected',
pollingPaused: true, pollingPaused: true,
state: snapshot.state, state: snapshot.state,
meters: snapshot.meters, input_meters: snapshot.input_meters,
output_meters: snapshot.output_meters,
}; };
} }
+8 -3
View File
@@ -242,7 +242,8 @@ export type DSPMode = 'demo' | 'disconnected' | 'connected';
export type DSP408Snapshot = { export type DSP408Snapshot = {
state: DSPState; state: DSPState;
meters: Meters; input_meters: DSP408InputMeters;
output_meters: DSP408OutputMeters;
mode: DSPMode; mode: DSPMode;
}; };
@@ -252,6 +253,10 @@ export interface Meter {
clip: boolean; clip: boolean;
} }
export interface Meters { export interface DSP408InputMeters {
channels: Meter[]; meters: Record<InputChannel, Meter>;
}
export interface DSP408OutputMeters {
meters: Record<OutputChannel, Meter>;
} }
+8 -2
View File
@@ -1,4 +1,9 @@
import { DSPState as DSP408State, Meters as DSP408Meters, DSPMode } from './features/dsp408/types'; import {
DSPState as DSP408State,
DSPMode,
DSP408OutputMeters,
DSP408InputMeters,
} from './features/dsp408/types';
export type DSPStatus = 'connected' | 'connecting' | 'disconnected'; export type DSPStatus = 'connected' | 'connecting' | 'disconnected';
@@ -41,7 +46,8 @@ interface DSPBase {
export type DSP408 = DSPBase & { export type DSP408 = DSPBase & {
type: 'DSP408'; type: 'DSP408';
state: DSP408State; state: DSP408State;
meters: DSP408Meters; input_meters: DSP408InputMeters;
output_meters: DSP408OutputMeters;
}; };
export type DSP204 = DSPBase & { export type DSP204 = DSPBase & {
+1 -1
View File
@@ -79,7 +79,7 @@
/* ---------- Card ---------- */ /* ---------- Card ---------- */
--card-width: 500px; --card-width: 500px;
--card-control-height: 36px; --card-control-height: 40px;
/* ---------- Button ---------- */ /* ---------- Button ---------- */
--disabled-opacity: 0.45; --disabled-opacity: 0.45;