feat: default meters + update state on link
CI / Rust CI (push) Failing after 47s

This commit is contained in:
2026-09-20 21:39:47 +02:00
parent a98be2f8e3
commit 3cf7c279a8
2 changed files with 83 additions and 11 deletions
+50 -6
View File
@@ -10,8 +10,7 @@ use std::{
use crate::{ use crate::{
common::errors::DSPError, common::errors::DSPError,
dsp408::{ dsp408::{
default::default_input_meters, default::{default_input_meters, default_output_meters},
default::default_output_meters,
default_dsp_state, default_dsp_state,
mapper::{ mapper::{
self, self,
@@ -19,7 +18,7 @@ use crate::{
response::map_response, response::map_response,
}, },
protocol::{commands, config::decode_config, frame::extract_frame}, protocol::{commands, config::decode_config, frame::extract_frame},
types::{self}, types::self,
}, },
}; };
@@ -1514,9 +1513,6 @@ impl DSP408 {
if !self.request_acknowledgement()? { if !self.request_acknowledgement()? {
return Ok(false); return Ok(false);
} }
let config = self.read_config_state()?;
self.state_mut().current_config = config;
} }
types::DSPMode::Demo => { types::DSPMode::Demo => {
@@ -1528,6 +1524,54 @@ impl DSP408 {
} }
} }
let state = self.state_mut();
match source {
types::Channel::Input(s) => {
let input_destinations: Vec<types::InputChannel> = destinations
.iter()
.filter_map(|destination| match destination {
types::Channel::Input(input) => Some(*input),
types::Channel::Output(_) => None,
})
.collect();
let states = &mut state.current_config.input_states;
// Remove the source and destinations from all existing links.
for channel_state in states.values_mut() {
channel_state
.linked_channels
.retain(|channel| *channel != s && !input_destinations.contains(channel));
}
// Link source -> destinations.
states.get_mut(&s).unwrap().linked_channels = input_destinations;
}
types::Channel::Output(s) => {
let output_destinations: Vec<types::OutputChannel> = destinations
.iter()
.filter_map(|destination| match destination {
types::Channel::Output(output) => Some(*output),
types::Channel::Input(_) => None,
})
.collect();
let states = &mut state.current_config.output_states;
// Remove the source and destinations from all existing links.
for channel_state in states.values_mut() {
channel_state
.linked_channels
.retain(|channel| *channel != s && !output_destinations.contains(channel));
}
// Link source -> destinations.
states.get_mut(&s).unwrap().linked_channels = output_destinations;
}
}
Ok(true) Ok(true)
} }
+33 -5
View File
@@ -75,16 +75,44 @@ fn default_config() -> DSPConfigState {
fn default_input_states() -> HashMap<InputChannel, InputChannelState> { fn default_input_states() -> HashMap<InputChannel, InputChannelState> {
[ [
(InputChannel::InA, default_input_channel_state("In A")), (
(InputChannel::InB, default_input_channel_state("In B")), InputChannel::InA,
(InputChannel::InC, default_input_channel_state("In C")), default_input_channel_state("In A", false),
(InputChannel::InD, default_input_channel_state("In D")), ),
(InputChannel::InB, default_input_channel_state("In B", true)),
(
InputChannel::InC,
default_input_channel_state("In C", false),
),
(
InputChannel::InD,
default_input_channel_state("In D", false),
),
] ]
.into_iter() .into_iter()
.collect() .collect()
} }
fn default_input_channel_state(name: &str) -> InputChannelState { fn default_input_channel_state(name: &str, a: bool) -> InputChannelState {
if a {
return InputChannelState {
name: name.to_string(),
gain: 0.0,
phase_inverted: false,
delay: 0.0,
gate: default_gate(),
geq: default_graphic_eq(),
peq_chain: default_peq_chain(),
crossover: default_crossover_filters(),
linked_channels: vec![InputChannel::InA],
// linked_channels: Vec::new(),
mute: false,
};
}
InputChannelState { InputChannelState {
name: name.to_string(), name: name.to_string(),