use super::*;
pub struct Bus<'a> {
remote: &'a VoicemeeterRemote,
bus_index: ZIndex,
}
impl<'a> Bus<'a> {
#[doc(hidden)]
pub fn new(remote: &'a VoicemeeterRemote, bus_index: ZIndex) -> Self {
Bus { remote, bus_index }
}
pub fn param(&self, dot: impl ToString) -> Cow<'static, ParameterNameRef> {
Cow::Owned(format!("{BUS}[{}].{}", self.bus_index, dot.to_string()).into())
}
pub fn label(&self) -> StringParameter {
StringParameter::new(self.param("Label"), self.remote)
}
pub fn mono(&self) -> IntParameter {
IntParameter::new(self.param("Mono"), self.remote, 0..=2)
}
pub fn mute(&self) -> BoolParameter {
BoolParameter::new(self.param("Mute"), self.remote)
}
pub fn eq_on(&self) -> BoolParameter {
BoolParameter::new(self.param("EQ.on"), self.remote)
}
pub fn eq_ab(&self) -> BoolParameter {
BoolParameter::new(self.param("EQ.AB"), self.remote)
}
pub fn gain(&self) -> FloatParameter {
FloatParameter::new(self.param("gain"), self.remote, -60.0..=12.)
}
pub fn mode(&self) -> BusModeParameter {
BusModeParameter::new(self.remote, self.bus_index)
}
pub fn eq(&self, channel: usize) -> EqChannelParameter {
EqChannelParameter::new_bus(self.remote, self.bus_index, channel)
}
pub fn fade_to(&self) -> TupleParameter<'_, f32, usize> {
TupleParameter::new(self.param("FadeTo"), self.remote)
}
pub fn fade_by(&self) -> TupleParameter<'_, f32, usize> {
TupleParameter::new(self.param("FadeBy"), self.remote)
}
pub fn sel(&self) -> BoolParameter {
BoolParameter::new(self.param("Sel"), self.remote)
}
pub fn return_reverb(&self) -> IntParameter {
IntParameter::new(self.param("ReturnReverb"), self.remote, 0..=10)
}
pub fn return_delay(&self) -> IntParameter {
IntParameter::new(self.param("ReturnDelay"), self.remote, 0..=10)
}
pub fn return_fx1(&self) -> IntParameter {
IntParameter::new(self.param("ReturnFx1"), self.remote, 0..=10)
}
pub fn return_fx2(&self) -> IntParameter {
IntParameter::new(self.param("ReturnFx2"), self.remote, 0..=10)
}
pub fn monitor(&self) -> BoolParameter {
BoolParameter::new(self.param("Monitor"), self.remote)
}
pub fn device(&self) -> BusDevice {
BusDevice::new(self.remote, self.bus_index)
}
}
pub struct BusModeParameter<'a> {
remote: &'a VoicemeeterRemote,
bus_index: ZIndex,
}
impl<'a> BusModeParameter<'a> {
fn new(remote: &'a VoicemeeterRemote, bus_index: ZIndex) -> Self {
Self { remote, bus_index }
}
pub fn param(&self, dot: impl ToString) -> Cow<'static, ParameterNameRef> {
Cow::Owned(format!("{BUS}[{}].mode.{}", self.bus_index, dot.to_string()).into())
}
pub fn get(&self) -> Result<Option<BusMode>, GetParameterError> {
Ok(Some(if self.is_normal()? {
BusMode::Normal
} else if self.is_amix()? {
BusMode::Amix
} else if self.is_bmix()? {
BusMode::Bmix
} else if self.is_repeat()? {
BusMode::Repeat
} else if self.is_composite()? {
BusMode::Composite
} else if self.is_tv_mix()? {
BusMode::TvMix
} else if self.is_up_mix21()? {
BusMode::UpMix21
} else if self.is_up_mix41()? {
BusMode::UpMix41
} else if self.is_up_mix61()? {
BusMode::UpMix61
} else if self.is_center_only()? {
BusMode::CenterOnly
} else if self.is_lfe_only()? {
BusMode::LfeOnly
} else if self.is_rear_only()? {
BusMode::RearOnly
} else {
return Ok(None);
}))
}
pub fn set(&self, mode: BusMode) -> Result<(), SetParameterError> {
match mode {
BusMode::Normal => self.set_normal(true),
BusMode::Amix => self.set_amix(true),
BusMode::Bmix => self.set_bmix(true),
BusMode::Repeat => self.set_repeat(true),
BusMode::Composite => self.set_composite(true),
BusMode::TvMix => self.set_tv_mix(true),
BusMode::UpMix21 => self.set_up_mix21(true),
BusMode::UpMix41 => self.set_up_mix41(true),
BusMode::UpMix61 => self.set_up_mix61(true),
BusMode::CenterOnly => self.set_center_only(true),
BusMode::LfeOnly => self.set_lfe_only(true),
BusMode::RearOnly => self.set_rear_only(true),
}
}
pub fn is_normal(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("normal"), self.remote).get()
}
pub fn is_amix(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("Amix"), self.remote).get()
}
pub fn is_bmix(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("Bmix"), self.remote).get()
}
pub fn is_repeat(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("Repeat"), self.remote).get()
}
pub fn is_composite(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("Composite"), self.remote).get()
}
pub fn is_tv_mix(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("TVMix"), self.remote).get()
}
pub fn is_up_mix21(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("UpMix21"), self.remote).get()
}
pub fn is_up_mix41(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("UpMix41"), self.remote).get()
}
pub fn is_up_mix61(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("UpMix61"), self.remote).get()
}
pub fn is_center_only(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("CenterOnly"), self.remote).get()
}
pub fn is_lfe_only(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("LFEOnly"), self.remote).get()
}
pub fn is_rear_only(&self) -> Result<bool, GetParameterError> {
BoolParameter::<'_, false, true>::new(self.param("RearOnly"), self.remote).get()
}
pub fn set_normal(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("normal"), self.remote).set(val)
}
pub fn set_amix(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("Amix"), self.remote).set(val)
}
pub fn set_bmix(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("Bmix"), self.remote).set(val)
}
pub fn set_repeat(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("Repeat"), self.remote).set(val)
}
pub fn set_composite(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("Composite"), self.remote).set(val)
}
pub fn set_tv_mix(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("TVMix"), self.remote).set(val)
}
pub fn set_up_mix21(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("UpMix21"), self.remote).set(val)
}
pub fn set_up_mix41(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("UpMix41"), self.remote).set(val)
}
pub fn set_up_mix61(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("UpMix61"), self.remote).set(val)
}
pub fn set_center_only(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("CenterOnly"), self.remote).set(val)
}
pub fn set_lfe_only(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("LFEOnly"), self.remote).set(val)
}
pub fn set_rear_only(&self, val: bool) -> Result<(), SetParameterError> {
BoolParameter::<'_, true, false>::new(self.param("RearOnly"), self.remote).set(val)
}
}
pub struct BusDevice<'a> {
remote: &'a VoicemeeterRemote,
bus_index: ZIndex,
}
impl<'a> BusDevice<'a> {
#[doc(hidden)]
pub fn new(remote: &'a VoicemeeterRemote, bus_index: ZIndex) -> Self {
Self { remote, bus_index }
}
pub fn param(&self, dot: impl ToString) -> Cow<'static, ParameterNameRef> {
Cow::Owned(format!("{BUS}[{}].device.{}", self.bus_index, dot.to_string()).into())
}
pub fn name(&self) -> StringParameter<'a, false, true> {
StringParameter::new(self.param("name"), self.remote)
}
pub fn sr(&self) -> IntParameter<'a, false, true> {
IntParameter::new_unranged(self.param("sr"), self.remote)
}
pub fn wdm(&self) -> StringParameter<'a, true, false> {
StringParameter::new(self.param("wdm"), self.remote)
}
pub fn ks(&self) -> StringParameter<'a, true, false> {
StringParameter::new(self.param("ks"), self.remote)
}
pub fn mme(&self) -> StringParameter<'a, true, false> {
StringParameter::new(self.param("mme"), self.remote)
}
pub fn asio(&self) -> StringParameter<'a, true, false> {
StringParameter::new(self.param("asio"), self.remote)
}
}