fix: round trip value before putting in state so hardware and software stay in sync
CI / Rust CI (push) Successful in 45s

This commit is contained in:
Lucas
2026-09-25 15:11:03 +02:00
parent b8e3d870cb
commit 5c79deec56
+41 -32
View File
@@ -604,8 +604,9 @@ impl DSP408 {
// Shared authoritative state update.
let current_index = self.state().presets.current_index;
let name = mapper::raw_to_preset_name(&raw_name)?;
self.state_mut().presets.names[current_index - 1] = name.to_string();
self.state_mut().presets.names[current_index - 1] = name;
Ok(true)
}
@@ -892,11 +893,11 @@ impl DSP408 {
.current_config
.output_state_mut(channel)
.compressor = types::Compressor {
threshold,
ratio,
attack,
release,
knee,
threshold: mapper::raw_to_threshold_db(raw_threshold)?,
ratio: mapper::raw_to_ratio(raw_ratio)?,
attack: mapper::raw_to_attack_ms(raw_attack)?,
release: mapper::raw_to_release_ms(raw_release)?,
knee: mapper::raw_to_knee_db(raw_knee)?,
};
Ok(true)
@@ -953,8 +954,8 @@ impl DSP408 {
.input_state_mut(input)
.crossover
.low_pass = types::Crossover {
frequency: freq,
slope: filter_type,
frequency: mapper::raw_to_frequency_hz(raw_freq)?,
slope: mapper::raw_to_crossover_filter(raw_filter)?,
};
}
@@ -964,8 +965,8 @@ impl DSP408 {
.output_state_mut(output)
.crossover
.low_pass = types::Crossover {
frequency: freq,
slope: filter_type,
frequency: mapper::raw_to_frequency_hz(raw_freq)?,
slope: mapper::raw_to_crossover_filter(raw_filter)?,
};
}
}
@@ -1024,8 +1025,8 @@ impl DSP408 {
.input_state_mut(input)
.crossover
.high_pass = types::Crossover {
frequency: freq,
slope: filter_type,
frequency: mapper::raw_to_frequency_hz(raw_freq)?,
slope: mapper::raw_to_crossover_filter(raw_filter)?,
};
}
@@ -1035,8 +1036,8 @@ impl DSP408 {
.output_state_mut(output)
.crossover
.high_pass = types::Crossover {
frequency: freq,
slope: filter_type,
frequency: mapper::raw_to_frequency_hz(raw_freq)?,
slope: mapper::raw_to_crossover_filter(raw_filter)?,
};
}
}
@@ -1106,10 +1107,10 @@ impl DSP408 {
let state = self.state_mut();
let peq = types::PEQ {
gain: gain_db,
frequency: freq_hz,
q,
filter_type,
gain: mapper::raw_to_eq_gain(raw_gain)?,
frequency: mapper::raw_to_frequency_hz(raw_frequency)?,
q: mapper::raw_to_peq_q(raw_q)?,
filter_type: mapper::raw_to_peq_filter(raw_filter)?,
bypass,
};
@@ -1176,11 +1177,11 @@ impl DSP408 {
match channel {
types::Channel::Input(input) => {
state.current_config.input_state_mut(input).gain = db;
state.current_config.input_state_mut(input).gain = mapper::raw_to_gain(raw_db)?;
}
types::Channel::Output(output) => {
state.current_config.output_state_mut(output).gain = db;
state.current_config.output_state_mut(output).gain = mapper::raw_to_gain(raw_db)?;
}
}
@@ -1384,7 +1385,10 @@ impl DSP408 {
}
}
self.state_mut().current_config.input_source = input_source;
self.state_mut().current_config.input_source = types::InputSource {
r#type: mapper::raw_to_input_source(raw_source)?,
frequency: mapper::raw_to_frequency_value(raw_frequency)?,
};
Ok(true)
}
@@ -1677,11 +1681,13 @@ impl DSP408 {
match channel {
types::Channel::Input(input) => {
state.current_config.input_state_mut(input).name = name.to_string();
state.current_config.input_state_mut(input).name =
mapper::raw_to_channel_name(&raw_name)?;
}
types::Channel::Output(output) => {
state.current_config.output_state_mut(output).name = name.to_string();
state.current_config.output_state_mut(output).name =
mapper::raw_to_channel_name(&raw_name)?;
}
}
@@ -1744,10 +1750,10 @@ impl DSP408 {
.current_config
.input_state_mut(channel)
.gate = types::Gate {
attack,
release,
hold,
threshold,
attack: mapper::raw_to_attack_ms(raw_attack)?,
release: mapper::raw_to_release_ms(raw_release)?,
hold: mapper::raw_to_hold_ms(raw_hold)?,
threshold: mapper::raw_to_gate_threshold_db(raw_threshold)?,
};
Ok(true)
@@ -1806,9 +1812,9 @@ impl DSP408 {
.current_config
.output_state_mut(channel)
.limiter = types::Limiter {
threshold,
attack,
release,
threshold: mapper::raw_to_threshold_db(raw_threshold)?,
attack: mapper::raw_to_attack_ms(raw_attack)?,
release: mapper::raw_to_release_ms(raw_release)?,
};
Ok(true)
@@ -1895,7 +1901,7 @@ impl DSP408 {
.output_state_mut(output_channel)
.matrix_routes
.gains
.insert(input_channel, gain);
.insert(input_channel, mapper::raw_to_matrix_gain(raw_gain)?);
Ok(true)
}
@@ -1948,7 +1954,10 @@ impl DSP408 {
.input_state_mut(input_channel)
.geq
.gains
.insert(frequency_band, gain);
.insert(
mapper::raw_to_frequency_value(raw_frequency_band)?,
mapper::raw_to_eq_gain(raw_gain)?,
);
Ok(true)
}