use vst3::Steinberg::TUID;
pub const DEFAULT_SYSEX_SLOTS: usize = 16;
pub const DEFAULT_SYSEX_BUFFER_SIZE: usize = 512;
pub struct Vst3Config {
pub component_uid: TUID,
pub controller_uid: Option<TUID>,
pub categories: &'static str,
pub sysex_slots: usize,
pub sysex_buffer_size: usize,
}
impl Vst3Config {
pub const fn new(uuid: &'static str) -> Self {
const fn hex_to_u8(c: u8) -> u8 {
match c {
b'0'..=b'9' => c - b'0',
b'A'..=b'F' => c - b'A' + 10,
b'a'..=b'f' => c - b'a' + 10,
_ => panic!("Invalid hex character in UUID"),
}
}
const fn parse_u32(bytes: &[u8], start: usize) -> u32 {
let mut result: u32 = 0;
let mut i = 0;
let mut hex_count = 0;
while hex_count < 8 {
let c = bytes[start + i];
if c != b'-' {
result = (result << 4) | (hex_to_u8(c) as u32);
hex_count += 1;
}
i += 1;
}
result
}
let bytes = uuid.as_bytes();
let part1 = parse_u32(bytes, 0);
let part2 = parse_u32(bytes, 9);
let part3 = parse_u32(bytes, 19);
let part4 = parse_u32(bytes, 28);
let component_uid = vst3::uid(part1, part2, part3, part4);
Self {
component_uid,
controller_uid: None,
categories: "Fx",
sysex_slots: DEFAULT_SYSEX_SLOTS,
sysex_buffer_size: DEFAULT_SYSEX_BUFFER_SIZE,
}
}
pub const fn with_controller(mut self, controller_uid: TUID) -> Self {
self.controller_uid = Some(controller_uid);
self
}
pub const fn with_categories(mut self, categories: &'static str) -> Self {
self.categories = categories;
self
}
pub const fn with_sysex_slots(mut self, slots: usize) -> Self {
self.sysex_slots = slots;
self
}
pub const fn with_sysex_buffer_size(mut self, size: usize) -> Self {
self.sysex_buffer_size = size;
self
}
pub const fn has_controller(&self) -> bool {
self.controller_uid.is_some()
}
}