mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-08-07 22:17:07 +02:00
hoist connect_ fns
This commit is contained in:
parent
8b24b052ca
commit
815bfe9379
4 changed files with 56 additions and 57 deletions
113
src/sing.rs
113
src/sing.rs
|
|
@ -814,7 +814,6 @@ pub struct Connect {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connect {
|
impl Connect {
|
||||||
|
|
||||||
pub fn new <T: AsRef<str>> (
|
pub fn new <T: AsRef<str>> (
|
||||||
exact: Option<impl Iterator<Item = T>>,
|
exact: Option<impl Iterator<Item = T>>,
|
||||||
re: Option<impl Iterator<Item = T>>,
|
re: Option<impl Iterator<Item = T>>,
|
||||||
|
|
@ -827,62 +826,6 @@ impl Connect {
|
||||||
connections
|
connections
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn midi_ins <T: AsRef<str>> (
|
|
||||||
jack: &Jack<'static>,
|
|
||||||
name: &T,
|
|
||||||
midi_from: &[T],
|
|
||||||
midi_from_re: Option<&[T]>,
|
|
||||||
) -> Usually<Vec<MidiInput>> {
|
|
||||||
Ok(Connect::new(
|
|
||||||
Some(midi_from.into_iter()),
|
|
||||||
Some([].into_iter()),
|
|
||||||
midi_from_re.map(|x|x.into_iter())).iter().enumerate()
|
|
||||||
.map(|(index, connect)|jack.midi_in(&format!("{}/{index}", name.as_ref()), &[connect.clone()]))
|
|
||||||
.collect::<Result<_, _>>()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn midi_outs <T: AsRef<str>> (
|
|
||||||
jack: &Jack<'static>,
|
|
||||||
name: &T,
|
|
||||||
midi_to: &[T],
|
|
||||||
midi_to_re: Option<&[T]>,
|
|
||||||
) -> Usually<Vec<MidiOutput>> {
|
|
||||||
Ok(Connect::new(
|
|
||||||
Some(midi_to.into_iter()),
|
|
||||||
Some([].into_iter()),
|
|
||||||
midi_to_re.map(|x|x.into_iter())).iter().enumerate()
|
|
||||||
.map(|(index, connect)|jack.midi_out(&format!("{index}/{}", name.as_ref()), &[connect.clone()]))
|
|
||||||
.collect::<Result<_, _>>()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn audio_ins <T: AsRef<str>> (
|
|
||||||
jack: &Jack<'static>,
|
|
||||||
name: &T,
|
|
||||||
audio_from: &[T],
|
|
||||||
audio_from_re: Option<&[T]>,
|
|
||||||
) -> Usually<Vec<AudioInput>> {
|
|
||||||
Ok(Connect::new(
|
|
||||||
Some(audio_from.into_iter()),
|
|
||||||
Some([].into_iter()),
|
|
||||||
audio_from_re.map(|x|x.into_iter())).iter().enumerate()
|
|
||||||
.map(|(index, connect)|jack.audio_in(&format!("{}/{index}", name.as_ref()), &[connect.clone()]))
|
|
||||||
.collect::<Result<_, _>>()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn audio_outs <T: AsRef<str>> (
|
|
||||||
jack: &Jack<'static>,
|
|
||||||
name: &T,
|
|
||||||
audio_to: &[T],
|
|
||||||
audio_to_re: Option<&[T]>,
|
|
||||||
) -> Usually<Vec<AudioOutput>> {
|
|
||||||
Ok(Connect::new(
|
|
||||||
Some(audio_to.into_iter()),
|
|
||||||
Some([].into_iter()),
|
|
||||||
audio_to_re.map(|x|x.into_iter())).iter().enumerate()
|
|
||||||
.map(|(index, connect)|jack.audio_out(&format!("{index}/{}", name.as_ref()), &[connect.clone()]))
|
|
||||||
.collect::<Result<_, _>>()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Connect to this exact port
|
/// Connect to this exact port
|
||||||
pub fn exact (name: impl AsRef<str>) -> Self {
|
pub fn exact (name: impl AsRef<str>) -> Self {
|
||||||
let info = format!("=:{}", name.as_ref()).into();
|
let info = format!("=:{}", name.as_ref()).into();
|
||||||
|
|
@ -923,3 +866,59 @@ impl Connect {
|
||||||
}).into()
|
}).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn connect_midi_ins <T: AsRef<str>> (
|
||||||
|
jack: &Jack<'static>,
|
||||||
|
name: &T,
|
||||||
|
midi_from: &[T],
|
||||||
|
midi_from_re: Option<&[T]>,
|
||||||
|
) -> Usually<Vec<MidiInput>> {
|
||||||
|
Ok(Connect::new(
|
||||||
|
Some(midi_from.into_iter()),
|
||||||
|
Some([].into_iter()),
|
||||||
|
midi_from_re.map(|x|x.into_iter())).iter().enumerate()
|
||||||
|
.map(|(index, connect)|jack.midi_in(&format!("{}/{index}", name.as_ref()), &[connect.clone()]))
|
||||||
|
.collect::<Result<_, _>>()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connect_midi_outs <T: AsRef<str>> (
|
||||||
|
jack: &Jack<'static>,
|
||||||
|
name: &T,
|
||||||
|
midi_to: &[T],
|
||||||
|
midi_to_re: Option<&[T]>,
|
||||||
|
) -> Usually<Vec<MidiOutput>> {
|
||||||
|
Ok(Connect::new(
|
||||||
|
Some(midi_to.into_iter()),
|
||||||
|
Some([].into_iter()),
|
||||||
|
midi_to_re.map(|x|x.into_iter())).iter().enumerate()
|
||||||
|
.map(|(index, connect)|jack.midi_out(&format!("{index}/{}", name.as_ref()), &[connect.clone()]))
|
||||||
|
.collect::<Result<_, _>>()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connect_audio_ins <T: AsRef<str>> (
|
||||||
|
jack: &Jack<'static>,
|
||||||
|
name: &T,
|
||||||
|
audio_from: &[T],
|
||||||
|
audio_from_re: Option<&[T]>,
|
||||||
|
) -> Usually<Vec<AudioInput>> {
|
||||||
|
Ok(Connect::new(
|
||||||
|
Some(audio_from.into_iter()),
|
||||||
|
Some([].into_iter()),
|
||||||
|
audio_from_re.map(|x|x.into_iter())).iter().enumerate()
|
||||||
|
.map(|(index, connect)|jack.audio_in(&format!("{}/{index}", name.as_ref()), &[connect.clone()]))
|
||||||
|
.collect::<Result<_, _>>()?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn connect_audio_outs <T: AsRef<str>> (
|
||||||
|
jack: &Jack<'static>,
|
||||||
|
name: &T,
|
||||||
|
audio_to: &[T],
|
||||||
|
audio_to_re: Option<&[T]>,
|
||||||
|
) -> Usually<Vec<AudioOutput>> {
|
||||||
|
Ok(Connect::new(
|
||||||
|
Some(audio_to.into_iter()),
|
||||||
|
Some([].into_iter()),
|
||||||
|
audio_to_re.map(|x|x.into_iter())).iter().enumerate()
|
||||||
|
.map(|(index, connect)|jack.audio_out(&format!("{index}/{}", name.as_ref()), &[connect.clone()]))
|
||||||
|
.collect::<Result<_, _>>()?)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue