Files
dsp-thomann/src/dsp408/protocol/constants.rs
T
2026-08-01 12:45:58 +02:00

80 lines
2.7 KiB
Rust

use std::ops::RangeInclusive;
pub const DELAY_UNIT_RAW_RANGE: RangeInclusive<u8> = 0x00..=0x03;
pub const PRESET_INDEX_MAX: u8 = 20;
pub const CONFIG_CHUNK_INDEX_MAX: u8 = 0x1C;
pub const PRESET_NAME_LENGTH: usize = 14;
pub const PRESET_NAME_PADDING: u8 = 0x20;
pub const PASSWORD_LENGTH: usize = 4;
pub const PASSWORD_PADDING: u8 = 0x00;
pub const CHANNELS_RANGE: RangeInclusive<u8> = 0x00..=0x0B;
pub const INPUT_CHANNELS: RangeInclusive<u8> = 0x00..=0x03;
pub const OUTPUT_CHANNELS: RangeInclusive<u8> = 0x04..=0x0B;
pub const RATIO_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x000F;
pub const ATTACK_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x03E6;
pub const RELEASE_RAW_RANGE: RangeInclusive<u16> = 0x0009..=0x0BB7;
pub const KNEE_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x000C;
pub const THRESHOLD_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x00DC;
pub const FREQUENCY_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x012C;
pub const CROSSOVER_FILTER_RAW_RANGE: RangeInclusive<u8> = 0x00..=0x14;
pub const EQ_GAIN_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x00F0;
pub const PEQ_Q_RAW_RANGE: RangeInclusive<u8> = 0x00..=0x64;
pub const PEQ_INPUT_BAND_RANGE: RangeInclusive<u8> = 0x00..=0x07;
pub const PEQ_OUTPUT_BAND_RANGE: RangeInclusive<u8> = 0x00..=0x08;
pub const PEQ_FILTER_RAW_RANGE: RangeInclusive<u8> = 0x00..=0x08;
pub const CHANNEL_GAIN_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x0190;
pub const DELAY_RAW_RANGE: RangeInclusive<u8> = 0x00..=0xFF;
pub const INPUT_SOURCE_TYPE_RAW_RANGE: RangeInclusive<u8> = 0x00..=0x03;
pub const DISCRETE_FREQUENCY_RAW_RANGE: RangeInclusive<u8> = 0x00..=0x1E;
pub const MATRIX_INPUT_MASK_RANGE: RangeInclusive<u8> = 0x00..=0x0F;
pub const MATRIX_INPUT_A_MASK: u8 = 0x01;
pub const MATRIX_INPUT_B_MASK: u8 = 0x02;
pub const MATRIX_INPUT_C_MASK: u8 = 0x04;
pub const MATRIX_INPUT_D_MASK: u8 = 0x08;
pub const CHANNEL_NAME_LENGTH: usize = 8;
pub const CHANNEL_NAME_PADDING: u8 = 0x00;
pub const GATE_THRESHOLD_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x00B4;
pub const HOLD_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x03E6;
pub const MATRIX_GAIN_RAW_RANGE: RangeInclusive<u16> = 0x0000..=0x0118;
pub fn input_link_mask(channel: u8) -> Option<u8> {
match channel {
0x00 => Some(0x0F), // A,B,C,D
0x01 => Some(0x0E), // B,C,D
0x02 => Some(0x0C), // C,D
0x03 => Some(0x08), // D
_ => None,
}
}
pub fn output_link_mask(channel: u8) -> Option<u8> {
match channel {
0x04 => Some(0xFF), // 1..8
0x05 => Some(0xFE), // 2..8
0x06 => Some(0xFC), // 3..8
0x07 => Some(0xF8), // 4..8
0x08 => Some(0xF0), // 5..8
0x09 => Some(0xE0), // 6..8
0x0A => Some(0xC0), // 7..8
0x0B => Some(0x80), // 8
_ => None,
}
}