mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
ports macro
This commit is contained in:
parent
2067004d4a
commit
e86be4facc
10 changed files with 104 additions and 102 deletions
|
|
@ -43,6 +43,15 @@ impl Track {
|
|||
device: 0,
|
||||
})
|
||||
}
|
||||
pub fn device (&self) -> Option<&Box<dyn Device>> {
|
||||
self.devices.get(self.device)
|
||||
}
|
||||
pub fn first_device (&self) -> Option<&Box<dyn Device>> {
|
||||
self.devices.get(0)
|
||||
}
|
||||
pub fn last_device (&self) -> Option<&Box<dyn Device>> {
|
||||
self.devices.get(self.devices.len().saturating_sub(1))
|
||||
}
|
||||
pub fn phrase (&self) -> Option<&Phrase> {
|
||||
if let Some(phrase) = self.sequence {
|
||||
return self.phrases.get(phrase)
|
||||
|
|
@ -52,23 +61,24 @@ impl Track {
|
|||
}
|
||||
}
|
||||
|
||||
impl PortList for Track {
|
||||
fn midi_outs (&self) -> Usually<Vec<String>> {
|
||||
Ok(vec![self.midi_out.name()?])
|
||||
ports!(Track {
|
||||
audio: {
|
||||
outs: |track|{
|
||||
if let Some(device) = track.last_device() {
|
||||
device.audio_outs()
|
||||
} else {
|
||||
Ok(vec![])
|
||||
}
|
||||
},
|
||||
}
|
||||
fn midi_ins (&self) -> Usually<Vec<String>> {
|
||||
if let Some(device) = self.devices.get(0) {
|
||||
midi: {
|
||||
ins: |track|if let Some(device) = track.first_device() {
|
||||
device.midi_ins()
|
||||
} else {
|
||||
Ok(vec![])
|
||||
}
|
||||
},
|
||||
outs: |track|Ok(vec![
|
||||
&track.midi_out
|
||||
]),
|
||||
}
|
||||
fn audio_outs (&self) -> Usually<Vec<String>> {
|
||||
if let Some(device) = self.devices.get(self.devices.len().saturating_sub(1)) {
|
||||
device.audio_outs()
|
||||
} else {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue