mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
fix connecting track devices
This commit is contained in:
parent
eeb2faf064
commit
14b504374f
4 changed files with 52 additions and 27 deletions
26
src/edn.rs
26
src/edn.rs
|
|
@ -83,12 +83,24 @@ impl Track {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
let (left, right) = (app.audio_out(0), app.audio_out(1));
|
||||
app.add_track_with_cb(Some(name.as_str()), move|_, track|{
|
||||
for phrase in phrases {
|
||||
track.phrases.push(phrase);
|
||||
}
|
||||
for device in devices {
|
||||
track.add_device(device);
|
||||
track.add_device(device)?;
|
||||
}
|
||||
if let Some(device) = track.devices.get(0) {
|
||||
device.connect_midi_in(0, &track.midi_out.clone_unowned())?;
|
||||
}
|
||||
if let Some(device) = track.devices.get(track.devices.len() - 1) {
|
||||
if let Some(ref left) = left {
|
||||
device.connect_audio_out(0, left)?;
|
||||
}
|
||||
if let Some(ref right) = right {
|
||||
device.connect_audio_out(1, right)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
|
|
@ -133,10 +145,12 @@ impl Phrase {
|
|||
if !data.contains_key(&time) {
|
||||
data.insert(time, vec![]);
|
||||
}
|
||||
data.get_mut(&time).unwrap().push(MidiMessage::NoteOn {
|
||||
key: u7::from(*key as u8),
|
||||
vel: u7::from(*vel as u8),
|
||||
});
|
||||
let (key, vel) = (
|
||||
u7::from((*key as u8).min(127)),
|
||||
u7::from((*vel as u8).min(127))
|
||||
);
|
||||
data.get_mut(&time).unwrap()
|
||||
.push(MidiMessage::NoteOn { key, vel })
|
||||
} else {
|
||||
panic!("unexpected list in phrase '{name}'")
|
||||
},
|
||||
|
|
@ -228,7 +242,7 @@ impl LV2Plugin {
|
|||
path = String::from(*p);
|
||||
}
|
||||
},
|
||||
_ => panic!("unexpected in sample {name}"),
|
||||
_ => panic!("unexpected in lv2 '{name}'"),
|
||||
}
|
||||
}
|
||||
Plugin::lv2(&name, &path)
|
||||
|
|
|
|||
|
|
@ -66,13 +66,15 @@ pub fn main () -> Usually<()> {
|
|||
.collect::<Usually<()>>())
|
||||
.collect::<Usually<()>>()?;
|
||||
|
||||
let audio_outs: Vec<_> = audio_into
|
||||
state.audio_outs = audio_into
|
||||
.iter()
|
||||
.map(|name|client
|
||||
.ports(Some(name), None, PortFlags::empty())
|
||||
.get(0)
|
||||
.map(|name|client.port_by_name(name)))
|
||||
.flatten()
|
||||
.filter_map(|x|x)
|
||||
.map(Arc::new)
|
||||
.collect();
|
||||
|
||||
state.jack = Some(jack);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub struct App {
|
|||
/// Main MIDI controller.
|
||||
pub midi_in: Option<Port<MidiIn>>,
|
||||
/// Main audio outputs.
|
||||
pub audio_outs: Option<Vec<Port<AudioOut>>>,
|
||||
pub audio_outs: Vec<Arc<Port<Unowned>>>,
|
||||
/// JACK transport handle.
|
||||
pub transport: Option<Transport>,
|
||||
/// Current transport state
|
||||
|
|
@ -124,6 +124,9 @@ impl App {
|
|||
reset, current_frames as usize, current_usecs as usize, next_usecs as usize, period_usecs as f64
|
||||
)
|
||||
}
|
||||
pub fn audio_out (&self, index: usize) -> Option<Arc<Port<Unowned>>> {
|
||||
self.audio_outs.get(index).map(|x|x.clone())
|
||||
}
|
||||
pub fn client (&self) -> &Client {
|
||||
self.jack.as_ref().unwrap().as_client()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue