diff --git a/README.md b/README.md index 102e366..6a7e457 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,6 @@ This template should help get you started developing with Tauri, React and Types ## Recommended IDE Setup - [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) + +# TODO +- Move meters polling logic outside dsp state because it causes re-render of everything tied to dsp constantly \ No newline at end of file diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index a9fefec..09d0293 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -1,6 +1,6 @@ use tauri::State; use crate::state::{AppState, DSPDevice}; -use dsp_thomann::dsp408::DSP408; +use dsp_thomann::dsp408::{DSP408, types}; use std::{net::IpAddr, str::FromStr}; use std::sync::{Arc, Mutex}; @@ -246,4 +246,22 @@ pub async fn set_current_preset_name( .set_current_preset_name(&name) .map_err(|e| e.to_string()) }) -} \ No newline at end of file +} + +#[tauri::command] +pub async fn set_gate( + state: State<'_, AppState>, + id: u64, + channel: types::InputChannel, + threshold: f32, + attack: u16, + hold: u16, + release: u16, +) -> Result { + state.with_device_mut(id, |device| { + device + .dsp + .set_gate(channel, threshold, attack, hold, release) + .map_err(|e| e.to_string()) + }) +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 52c6f67..87db7cf 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -20,6 +20,7 @@ pub fn run() { commands::recall_preset, commands::get_meter_levels, commands::set_current_preset_name, + commands::set_gate, ] ) .run(tauri::generate_context!()) diff --git a/src/api/dsp408.ts b/src/api/dsp408.ts index bef3138..c90849f 100644 --- a/src/api/dsp408.ts +++ b/src/api/dsp408.ts @@ -1,5 +1,5 @@ import { invoke } from '@tauri-apps/api/core'; -import { DSPState, Meters } from '../types/dsp408State'; +import { DSPState, Meters, InputChannel } from '../types/dsp408State'; export const createDSP408 = (ip: string, port: number, deviceId: number) => invoke('create_dsp408', { @@ -29,3 +29,20 @@ export const DSP408SetCurrentPresetName = (id: number, name: string) => }); export const getDSP408MeterLevels = (id: number) => invoke('get_meter_levels', { id }); + +export const DSP408SetGate = ( + id: number, + channel: InputChannel, + threshold: number, + attack: number, + hold: number, + release: number +) => + invoke('set_gate', { + id, + channel, + threshold, + attack, + hold, + release, + }); diff --git a/src/components/Button/Button.css b/src/components/Button/Button.css index 50c0077..c5c35e7 100644 --- a/src/components/Button/Button.css +++ b/src/components/Button/Button.css @@ -66,4 +66,4 @@ .btn-toggle.active-warning:hover:not(:disabled) { background: var(--accent-connecting); border-color: var(--accent-connecting); -} \ No newline at end of file +} diff --git a/src/components/dsp408/ChannelGroup/ChannelGroup.css b/src/components/dsp408/ChannelGroup/ChannelGroup.css index 762c54d..f2de40e 100644 --- a/src/components/dsp408/ChannelGroup/ChannelGroup.css +++ b/src/components/dsp408/ChannelGroup/ChannelGroup.css @@ -38,4 +38,4 @@ align-items: stretch; height: 100%; gap: var(--space-1); -} \ No newline at end of file +} diff --git a/src/components/dsp408/GainSection/GainSection.tsx b/src/components/dsp408/GainSection/GainSection.tsx index fa75b60..d5d2601 100644 --- a/src/components/dsp408/GainSection/GainSection.tsx +++ b/src/components/dsp408/GainSection/GainSection.tsx @@ -81,7 +81,12 @@ function GainPanel({ style={{ width: 70, height: 250, flex: '0 0 auto' }} // pin to design size, disable its own auto-shrink /> -