feat: remove useless api file
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { DSPState, Meters, InputChannel } from '../types/dsp408State';
|
||||
|
||||
export const createDSP408 = (ip: string, port: number, deviceId: number) =>
|
||||
invoke<number>('create_dsp408', {
|
||||
ip,
|
||||
port,
|
||||
deviceId,
|
||||
});
|
||||
|
||||
export const removeDSP408 = (id: number) => invoke('remove_dsp408', { id });
|
||||
|
||||
export const connectDSP408 = (id: number) => invoke('connect_dsp408', { id });
|
||||
|
||||
export const disconnectDSP408 = (id: number) => invoke('disconnect_dsp408', { id });
|
||||
|
||||
export const getDSP408State = (id: number) => invoke<DSPState>('get_dsp_state', { id });
|
||||
|
||||
export const recallPresetDSP408 = (id: number, presetIndex: number) =>
|
||||
invoke<boolean>('recall_preset', {
|
||||
id,
|
||||
presetIndex,
|
||||
});
|
||||
|
||||
export const DSP408SetCurrentPresetName = (id: number, name: string) =>
|
||||
invoke<boolean>('set_current_preset_name', {
|
||||
id,
|
||||
name,
|
||||
});
|
||||
|
||||
export const getDSP408MeterLevels = (id: number) => invoke<Meters>('get_meter_levels', { id });
|
||||
|
||||
export const DSP408SetGate = (
|
||||
id: number,
|
||||
channel: InputChannel,
|
||||
threshold: number,
|
||||
attack: number,
|
||||
hold: number,
|
||||
release: number
|
||||
) =>
|
||||
invoke<boolean>('set_gate', {
|
||||
id,
|
||||
channel,
|
||||
threshold,
|
||||
attack,
|
||||
hold,
|
||||
release,
|
||||
});
|
||||
+76
-24
@@ -12,18 +12,20 @@ import {
|
||||
OutputChannel,
|
||||
Ratio,
|
||||
DelayUnit,
|
||||
Meters,
|
||||
DSPState,
|
||||
} from '../types/dsp408State';
|
||||
|
||||
import {
|
||||
createDSP408,
|
||||
removeDSP408,
|
||||
connectDSP408,
|
||||
disconnectDSP408,
|
||||
getDSP408State,
|
||||
recallPresetDSP408,
|
||||
DSP408SetCurrentPresetName,
|
||||
getDSP408MeterLevels,
|
||||
} from '../api/dsp408';
|
||||
// import {
|
||||
// createDSP408,
|
||||
// removeDSP408,
|
||||
// connectDSP408,
|
||||
// disconnectDSP408,
|
||||
// getDSP408State,
|
||||
// recallPresetDSP408,
|
||||
// DSP408SetCurrentPresetName,
|
||||
// getDSP408MeterLevels,
|
||||
// } from '../api/dsp408';
|
||||
|
||||
type NotifyFunction = (message: string, type: 'success' | 'error', dspName?: string) => void;
|
||||
|
||||
@@ -97,7 +99,9 @@ function useDSPPolling(
|
||||
}
|
||||
|
||||
try {
|
||||
const meters = await getDSP408MeterLevels(dsp.id);
|
||||
const meters = await invoke<Meters>('get_meter_levels', {
|
||||
id: dsp.id,
|
||||
});
|
||||
|
||||
if (stopped) return;
|
||||
|
||||
@@ -207,9 +211,11 @@ export function useDSP408(
|
||||
}));
|
||||
|
||||
try {
|
||||
await connectDSP408(dsp.id);
|
||||
await invoke<DSPState>('connect_dsp408', { id: dsp.id });
|
||||
|
||||
const state = await getDSP408State(dsp.id);
|
||||
const state = await invoke<DSPState>('get_dsp_state', {
|
||||
id: dsp.id,
|
||||
});
|
||||
|
||||
updateDSP(setDsps, dsp.id, (d) => ({
|
||||
...d,
|
||||
@@ -234,7 +240,7 @@ export function useDSP408(
|
||||
setPollingPaused(dsp.id, true);
|
||||
|
||||
try {
|
||||
await disconnectDSP408(dsp.id);
|
||||
await invoke('disconnect_dsp408', { id: dsp.id });
|
||||
|
||||
updateDSP(setDsps, dsp.id, (d) => ({
|
||||
...d,
|
||||
@@ -253,7 +259,11 @@ export function useDSP408(
|
||||
// Add / Remove
|
||||
async function addDSP(dsp: Omit<DSP, 'id' | 'status' | 'state' | 'meters' | 'pollingPaused'>) {
|
||||
try {
|
||||
const id = await createDSP408(dsp.ip, dsp.port, dsp.deviceId);
|
||||
const id = await invoke<number>('create_dsp408', {
|
||||
ip: dsp.ip,
|
||||
port: dsp.port,
|
||||
deviceId: dsp.deviceId,
|
||||
});
|
||||
|
||||
const newDsp: DSP = {
|
||||
id,
|
||||
@@ -278,7 +288,9 @@ export function useDSP408(
|
||||
setPollingPaused(dsp.id, true);
|
||||
|
||||
try {
|
||||
await removeDSP408(dsp.id);
|
||||
await invoke('remove_dsp408', {
|
||||
id: dsp.id,
|
||||
});
|
||||
|
||||
setDsps((prev) => {
|
||||
const next = prev.filter((d) => d.id !== dsp.id);
|
||||
@@ -302,7 +314,10 @@ export function useDSP408(
|
||||
async function recallPreset(dsp: DSP, presetIndex: number) {
|
||||
return withPollingPaused(dsp, async () => {
|
||||
try {
|
||||
const success = await recallPresetDSP408(dsp.id, presetIndex);
|
||||
const success = await invoke<boolean>('recall_preset', {
|
||||
id: dsp.id,
|
||||
presetIndex,
|
||||
});
|
||||
|
||||
if (!success) {
|
||||
notify('Failed to recall preset', 'error', dsp.name);
|
||||
@@ -341,7 +356,10 @@ export function useDSP408(
|
||||
try {
|
||||
const paddedName = name.slice(0, 14).padEnd(14, ' ');
|
||||
|
||||
const success = await DSP408SetCurrentPresetName(dsp.id, paddedName);
|
||||
const success = await invoke<boolean>('set_current_preset_name', {
|
||||
id: dsp.id,
|
||||
name: paddedName,
|
||||
});
|
||||
|
||||
if (!success) {
|
||||
notify('Failed to rename preset', 'error', dsp.name);
|
||||
@@ -393,16 +411,50 @@ export function useDSP408(
|
||||
|
||||
if (!success) {
|
||||
notify('Failed to set gain', 'error', dsp.name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const state = await getDSP408State(dsp.id);
|
||||
updateDSP(setDsps, dsp.id, (d) => {
|
||||
if (!d.state) return d;
|
||||
|
||||
updateDSP(setDsps, dsp.id, (d) => ({
|
||||
...d,
|
||||
state,
|
||||
}));
|
||||
const currentConfig = d.state.current_config;
|
||||
|
||||
if ('Input' in channel) {
|
||||
return {
|
||||
...d,
|
||||
state: {
|
||||
...d.state,
|
||||
current_config: {
|
||||
...currentConfig,
|
||||
input_states: {
|
||||
...currentConfig.input_states,
|
||||
[channel.Input]: {
|
||||
...currentConfig.input_states[channel.Input],
|
||||
gain,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...d,
|
||||
state: {
|
||||
...d.state,
|
||||
current_config: {
|
||||
...currentConfig,
|
||||
output_states: {
|
||||
...currentConfig.output_states,
|
||||
[channel.Output]: {
|
||||
...currentConfig.output_states[channel.Output],
|
||||
gain,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
notify('Gain updated', 'success', dsp.name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user