feat: Add Mic Sensitivity Noise Gate slider and core audio gating
This commit is contained in:
@@ -39,6 +39,7 @@ pub enum AppMessage {
|
||||
PeerVolumeChanged(EndpointId, f32),
|
||||
InputDeviceSelected(AudioDevice),
|
||||
OutputDeviceSelected(AudioDevice),
|
||||
NoiseGateChanged(f32),
|
||||
EventOccurred(Event),
|
||||
NavigateToSettings,
|
||||
NavigateBack,
|
||||
@@ -89,6 +90,7 @@ impl Default for AppState {
|
||||
let _ = UI_RX.set(Mutex::new(Some(ui_rx)));
|
||||
|
||||
let config = AppConfig::load();
|
||||
let _ = controller.send(CoreCommand::SetNoiseGateThreshold(config.noise_gate_threshold));
|
||||
let all_devices = enumerate_audio_devices();
|
||||
let input_devices: Vec<_> = all_devices.iter().filter(|d| d.is_input).cloned().collect();
|
||||
let output_devices: Vec<_> = all_devices.iter().filter(|d| !d.is_input).cloned().collect();
|
||||
@@ -251,6 +253,11 @@ fn update(state: &mut AppState, message: AppMessage) -> Task<AppMessage> {
|
||||
state.config.save();
|
||||
state.selected_output = Some(dev);
|
||||
}
|
||||
AppMessage::NoiseGateChanged(val) => {
|
||||
state.config.noise_gate_threshold = val;
|
||||
state.config.save();
|
||||
let _ = state.controller.send(CoreCommand::SetNoiseGateThreshold(val));
|
||||
}
|
||||
AppMessage::EventOccurred(Event::Keyboard(keyboard::Event::KeyPressed { key, .. })) => {
|
||||
if state.is_setting_hotkey {
|
||||
state.ptt_hotkey = key.clone();
|
||||
@@ -384,6 +391,11 @@ fn view(state: &AppState) -> Element<'_, AppMessage> {
|
||||
).width(iced::Length::Fixed(160.0))
|
||||
].spacing(4),
|
||||
].spacing(10),
|
||||
vertical_space(20.0),
|
||||
column![
|
||||
text(format!("Mic Sensitivity (Noise Gate): {:.1}%", state.config.noise_gate_threshold * 100.0)).size(14).color(color_subtext),
|
||||
slider(0.0..=0.1, state.config.noise_gate_threshold, AppMessage::NoiseGateChanged)
|
||||
].spacing(10).width(iced::Length::Fixed(320.0)),
|
||||
vertical_space(30.0),
|
||||
button(
|
||||
text("Back")
|
||||
|
||||
Reference in New Issue
Block a user