refactor: reorganize client constants
This commit is contained in:
@@ -14,41 +14,15 @@ pub const PASSWORD_PADDING: u8 = 0x00;
|
|||||||
|
|
||||||
pub const ATTACK_MS_RANGE: RangeInclusive<u16> = 1..=999;
|
pub const ATTACK_MS_RANGE: RangeInclusive<u16> = 1..=999;
|
||||||
pub const RELEASE_MS_RANGE: RangeInclusive<u16> = 10..=3000;
|
pub const RELEASE_MS_RANGE: RangeInclusive<u16> = 10..=3000;
|
||||||
pub const HOLD_MS_RANGE: RangeInclusive<u16> = 10..=999;
|
pub const KNEE_DB_RANGE: RangeInclusive<u16> = 0..=12;
|
||||||
pub const GATE_THRESHOLD_DB_RANGE: RangeInclusive<f32> = -90.0..=0.0;
|
|
||||||
pub const EQ_GAIN_DB_RANGE: RangeInclusive<f32> = -12.0..=12.0;
|
|
||||||
pub const COMPRESSOR_KNEE_DB_RANGE: RangeInclusive<u16> = 0..=12;
|
|
||||||
pub const THRESHOLD_DB_RANGE: RangeInclusive<f32> = -90.0..=20.0;
|
pub const THRESHOLD_DB_RANGE: RangeInclusive<f32> = -90.0..=20.0;
|
||||||
|
|
||||||
pub const FREQUENCY_HZ_RANGE: RangeInclusive<f32> = 19.7..=20160.0;
|
pub const FREQUENCY_HZ_RANGE: RangeInclusive<f32> = 19.7..=20160.0;
|
||||||
|
|
||||||
|
pub const EQ_GAIN_DB_RANGE: RangeInclusive<f32> = -12.0..=12.0;
|
||||||
pub const PEQ_Q_RANGE: RangeInclusive<f32> = 0.40..=128.0;
|
pub const PEQ_Q_RANGE: RangeInclusive<f32> = 0.40..=128.0;
|
||||||
pub const PEQ_INPUT_BAND_COUNT: usize = 8;
|
pub const PEQ_INPUT_BAND_COUNT: usize = 8;
|
||||||
pub const PEQ_OUTPUT_BAND_COUNT:usize = 9;
|
pub const PEQ_OUTPUT_BAND_COUNT:usize = 9;
|
||||||
|
|
||||||
pub const GAIN_DB_RANGE: RangeInclusive<f32> = -60.0..=12.0;
|
|
||||||
pub const GAIN_SPLIT_DB: f32 = -20.0;
|
|
||||||
pub const GAIN_LOW_STEP_DB: f32 = 0.5;
|
|
||||||
pub const GAIN_HIGH_STEP_DB: f32 = 0.1;
|
|
||||||
|
|
||||||
pub const CHANNEL_NAME_LENGTH: usize = 8;
|
|
||||||
pub const CHANNEL_NAME_PADDING: u8 = 0x00;
|
|
||||||
|
|
||||||
pub const METERS_SPLIT: f32 = 1.0;
|
|
||||||
pub const METERS_SPLIT_LEVEL: f32 = -18.0;
|
|
||||||
pub const METERS_LOW_STEP: f32 = 0.0104;
|
|
||||||
pub const METERS_HIGH_STEP: f32 = 0.0208;
|
|
||||||
|
|
||||||
pub const MATRIX_GAIN_DB_RANGE: RangeInclusive<f32> = -60.0..=0.0;
|
|
||||||
|
|
||||||
pub fn delay_range(unit: DelayUnit) -> (f32, f32) {
|
|
||||||
match unit {
|
|
||||||
DelayUnit::Millisecond => (0.000, 680.000),
|
|
||||||
DelayUnit::Meter => (0.000, 233.580),
|
|
||||||
DelayUnit::Feet => (0.000, 766.329),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn peq_q_range(filter: PEQFilter) -> RangeInclusive<f32> {
|
pub fn peq_q_range(filter: PEQFilter) -> RangeInclusive<f32> {
|
||||||
match filter {
|
match filter {
|
||||||
PEQFilter::Peak
|
PEQFilter::Peak
|
||||||
@@ -67,3 +41,29 @@ pub fn peq_q_range(filter: PEQFilter) -> RangeInclusive<f32> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const GAIN_DB_RANGE: RangeInclusive<f32> = -60.0..=12.0;
|
||||||
|
pub const GAIN_SPLIT_DB: f32 = -20.0;
|
||||||
|
pub const GAIN_LOW_STEP_DB: f32 = 0.5;
|
||||||
|
pub const GAIN_HIGH_STEP_DB: f32 = 0.1;
|
||||||
|
|
||||||
|
pub fn delay_range(unit: DelayUnit) -> (f32, f32) {
|
||||||
|
match unit {
|
||||||
|
DelayUnit::Millisecond => (0.000, 680.000),
|
||||||
|
DelayUnit::Meter => (0.000, 233.580),
|
||||||
|
DelayUnit::Feet => (0.000, 766.329),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const CHANNEL_NAME_LENGTH: usize = 8;
|
||||||
|
pub const CHANNEL_NAME_PADDING: u8 = 0x00;
|
||||||
|
|
||||||
|
pub const GATE_THRESHOLD_DB_RANGE: RangeInclusive<f32> = -90.0..=0.0;
|
||||||
|
pub const HOLD_MS_RANGE: RangeInclusive<u16> = 10..=999;
|
||||||
|
|
||||||
|
pub const MATRIX_GAIN_DB_RANGE: RangeInclusive<f32> = -60.0..=0.0;
|
||||||
|
|
||||||
|
pub const METERS_SPLIT: f32 = 1.0;
|
||||||
|
pub const METERS_SPLIT_LEVEL_DB: f32 = -18.0;
|
||||||
|
pub const METERS_LOW_STEP: f32 = 0.0104;
|
||||||
|
pub const METERS_HIGH_STEP: f32 = 0.0208;
|
||||||
@@ -615,7 +615,7 @@ pub fn raw_to_ratio(value: u16) -> Result<types::Ratio, MapperError> {
|
|||||||
pub fn knee_db_to_raw(db: u16) -> Result<u16, MapperError> {
|
pub fn knee_db_to_raw(db: u16) -> Result<u16, MapperError> {
|
||||||
validate_range(
|
validate_range(
|
||||||
db,
|
db,
|
||||||
client_constants::COMPRESSOR_KNEE_DB_RANGE,
|
client_constants::KNEE_DB_RANGE,
|
||||||
|| format!("Invalid compressor knee: {db}"),
|
|| format!("Invalid compressor knee: {db}"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::dsp408::client::constants::{METERS_HIGH_STEP, METERS_LOW_STEP, METERS_SPLIT, METERS_SPLIT_LEVEL};
|
use crate::dsp408::client::constants::{METERS_HIGH_STEP, METERS_LOW_STEP, METERS_SPLIT, METERS_SPLIT_LEVEL_DB};
|
||||||
use crate::dsp408::client::types::{
|
use crate::dsp408::client::types::{
|
||||||
Acknowledgement, AuthenticationResult, ConfigChunk, CurrentPreset, DeviceFlags, DeviceInfo,
|
Acknowledgement, AuthenticationResult, ConfigChunk, CurrentPreset, DeviceFlags, DeviceInfo,
|
||||||
DeviceResponseType, HandshakeAck, Meters, ModifiedPreset, NotImplemented, PresetName,
|
DeviceResponseType, HandshakeAck, Meters, ModifiedPreset, NotImplemented, PresetName,
|
||||||
@@ -173,9 +173,9 @@ pub fn map_response(frame: &Frame) -> Result<DeviceResponseType, ProtocolError>
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if f < METERS_SPLIT {
|
if f < METERS_SPLIT {
|
||||||
METERS_SPLIT_LEVEL + (f - METERS_SPLIT) / METERS_LOW_STEP
|
METERS_SPLIT_LEVEL_DB + (f - METERS_SPLIT) / METERS_LOW_STEP
|
||||||
} else {
|
} else {
|
||||||
METERS_SPLIT_LEVEL + (f - METERS_SPLIT) / METERS_HIGH_STEP
|
METERS_SPLIT_LEVEL_DB + (f - METERS_SPLIT) / METERS_HIGH_STEP
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
Reference in New Issue
Block a user