mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
autoconnect newly added sampler
This commit is contained in:
parent
ebd0f18c9c
commit
16e9405b1f
2 changed files with 27 additions and 19 deletions
|
|
@ -393,6 +393,13 @@ impl Tek {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn device_kinds (&self) -> &'static [&'static str] {
|
||||||
|
&[
|
||||||
|
"Sampler",
|
||||||
|
"Plugin (LV2)",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn device_picker_show (&mut self) {
|
pub(crate) fn device_picker_show (&mut self) {
|
||||||
self.modal = Some(Modal::Device(0));
|
self.modal = Some(Modal::Device(0));
|
||||||
}
|
}
|
||||||
|
|
@ -403,30 +410,30 @@ impl Tek {
|
||||||
|
|
||||||
pub(crate) fn device_add (&mut self, index: usize) -> Usually<()> {
|
pub(crate) fn device_add (&mut self, index: usize) -> Usually<()> {
|
||||||
match index {
|
match index {
|
||||||
0 => {
|
0 => self.device_add_sampler(),
|
||||||
let jack = self.jack.clone();
|
|
||||||
let sampler = if let Ok(sampler) = Sampler::new(
|
|
||||||
&jack, &"sampler", &[], &[&[], &[]], &[&[], &[]]
|
|
||||||
) {
|
|
||||||
self.modal = None;
|
|
||||||
Device::Sampler(sampler)
|
|
||||||
} else {
|
|
||||||
self.modal = Some(Modal::Message(Message::FailedToAddDevice));
|
|
||||||
return Err("failed to add device".into())
|
|
||||||
};
|
|
||||||
self.track_mut().expect("no active track").devices.push(sampler);
|
|
||||||
Ok(())
|
|
||||||
},
|
|
||||||
1 => todo!(),
|
1 => todo!(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn device_kinds (&self) -> &'static [&'static str] {
|
fn device_add_sampler (&mut self) -> Usually<()> {
|
||||||
&[
|
let jack = self.jack.clone();
|
||||||
"Sampler",
|
let midi_port = self.track().expect("no active track").player.midi_outs[0].name();
|
||||||
"Plugin (LV2)",
|
let sampler = if let Ok(sampler) = Sampler::new(
|
||||||
]
|
&jack,
|
||||||
|
&"sampler",
|
||||||
|
&[PortConnect::exact(format!("tek:{}", midi_port))], // FIXME
|
||||||
|
&[&[], &[]],
|
||||||
|
&[&[], &[]]
|
||||||
|
) {
|
||||||
|
self.modal = None;
|
||||||
|
Device::Sampler(sampler)
|
||||||
|
} else {
|
||||||
|
self.modal = Some(Modal::Message(Message::FailedToAddDevice));
|
||||||
|
return Err("failed to add device".into())
|
||||||
|
};
|
||||||
|
self.track_mut().expect("no active track").devices.push(sampler);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn message_dismiss (&mut self) {
|
pub(crate) fn message_dismiss (&mut self) {
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ pub trait JackPortAutoconnect: JackPort + for<'a>JackPortConnect<&'a Port<Unowne
|
||||||
}
|
}
|
||||||
fn connect_to_matching (&self) -> Usually<()> {
|
fn connect_to_matching (&self) -> Usually<()> {
|
||||||
for connect in self.conn().iter() {
|
for connect in self.conn().iter() {
|
||||||
|
//panic!("{connect:?}");
|
||||||
let status = match &connect.name {
|
let status = match &connect.name {
|
||||||
Exact(name) => self.connect_exact(name),
|
Exact(name) => self.connect_exact(name),
|
||||||
RegExp(re) => self.connect_regexp(re, connect.scope),
|
RegExp(re) => self.connect_regexp(re, connect.scope),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue