mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-02-01 16:46:41 +01:00
wip: device: reenable lv2 support
This commit is contained in:
parent
bb325869c2
commit
6286d69824
18 changed files with 1533 additions and 393 deletions
50
crates/device/src/lv2/lv2_audio.rs
Normal file
50
crates/device/src/lv2/lv2_audio.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
use crate::*;
|
||||
use super::*;
|
||||
|
||||
audio!(|self: Lv2, _client, scope|{
|
||||
let Self {
|
||||
midi_ins,
|
||||
midi_outs,
|
||||
audio_ins,
|
||||
audio_outs,
|
||||
lv2_features,
|
||||
ref mut lv2_instance,
|
||||
ref mut lv2_input_buffer,
|
||||
..
|
||||
} = self;
|
||||
let urid = lv2_features.midi_urid();
|
||||
lv2_input_buffer.clear();
|
||||
for port in midi_ins.iter() {
|
||||
let mut atom = ::livi::event::LV2AtomSequence::new(
|
||||
&lv2_features,
|
||||
scope.n_frames() as usize
|
||||
);
|
||||
for event in port.iter(scope) {
|
||||
match event.bytes.len() {
|
||||
3 => atom.push_midi_event::<3>(
|
||||
event.time as i64,
|
||||
urid,
|
||||
&event.bytes[0..3]
|
||||
).unwrap(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
lv2_input_buffer.push(atom);
|
||||
}
|
||||
let mut outputs = vec![];
|
||||
for _ in midi_outs.iter() {
|
||||
outputs.push(::livi::event::LV2AtomSequence::new(
|
||||
lv2_features,
|
||||
scope.n_frames() as usize
|
||||
));
|
||||
}
|
||||
let ports = ::livi::EmptyPortConnections::new()
|
||||
.with_atom_sequence_inputs(lv2_input_buffer.iter())
|
||||
.with_atom_sequence_outputs(outputs.iter_mut())
|
||||
.with_audio_inputs(audio_ins.iter().map(|o|o.as_slice(scope)))
|
||||
.with_audio_outputs(audio_outs.iter_mut().map(|o|o.as_mut_slice(scope)));
|
||||
unsafe {
|
||||
lv2_instance.run(scope.n_frames() as usize, ports).unwrap()
|
||||
};
|
||||
Control::Continue
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue