autoconnect newly added sampler

This commit is contained in:
🪞👃🪞 2025-05-04 16:51:38 +03:00
parent ebd0f18c9c
commit 16e9405b1f
2 changed files with 27 additions and 19 deletions

View file

@ -393,6 +393,13 @@ impl Tek {
Ok(())
}
pub(crate) fn device_kinds (&self) -> &'static [&'static str] {
&[
"Sampler",
"Plugin (LV2)",
]
}
pub(crate) fn device_picker_show (&mut self) {
self.modal = Some(Modal::Device(0));
}
@ -403,10 +410,21 @@ impl Tek {
pub(crate) fn device_add (&mut self, index: usize) -> Usually<()> {
match index {
0 => {
0 => self.device_add_sampler(),
1 => todo!(),
_ => unreachable!(),
}
}
fn device_add_sampler (&mut self) -> Usually<()> {
let jack = self.jack.clone();
let midi_port = self.track().expect("no active track").player.midi_outs[0].name();
let sampler = if let Ok(sampler) = Sampler::new(
&jack, &"sampler", &[], &[&[], &[]], &[&[], &[]]
&jack,
&"sampler",
&[PortConnect::exact(format!("tek:{}", midi_port))], // FIXME
&[&[], &[]],
&[&[], &[]]
) {
self.modal = None;
Device::Sampler(sampler)
@ -416,17 +434,6 @@ impl Tek {
};
self.track_mut().expect("no active track").devices.push(sampler);
Ok(())
},
1 => todo!(),
_ => unreachable!(),
}
}
pub(crate) fn device_kinds (&self) -> &'static [&'static str] {
&[
"Sampler",
"Plugin (LV2)",
]
}
pub(crate) fn message_dismiss (&mut self) {

View file

@ -112,6 +112,7 @@ pub trait JackPortAutoconnect: JackPort + for<'a>JackPortConnect<&'a Port<Unowne
}
fn connect_to_matching (&self) -> Usually<()> {
for connect in self.conn().iter() {
//panic!("{connect:?}");
let status = match &connect.name {
Exact(name) => self.connect_exact(name),
RegExp(re) => self.connect_regexp(re, connect.scope),