mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
and back into 1 crate
This commit is contained in:
parent
307dab8686
commit
5e2e0438a4
99 changed files with 934 additions and 938 deletions
|
|
@ -1,85 +0,0 @@
|
|||
use crate::*;
|
||||
|
||||
/// A LV2 plugin.
|
||||
#[derive(Debug)]
|
||||
pub struct Lv2 {
|
||||
/// JACK client handle (needs to not be dropped for standalone mode to work).
|
||||
pub jack: Jack<'static>,
|
||||
pub name: Arc<str>,
|
||||
pub path: Option<Arc<str>>,
|
||||
pub selected: usize,
|
||||
pub mapping: bool,
|
||||
pub midi_ins: Vec<Port<MidiIn>>,
|
||||
pub midi_outs: Vec<Port<MidiOut>>,
|
||||
pub audio_ins: Vec<Port<AudioIn>>,
|
||||
pub audio_outs: Vec<Port<AudioOut>>,
|
||||
|
||||
pub lv2_world: livi::World,
|
||||
pub lv2_instance: livi::Instance,
|
||||
pub lv2_plugin: livi::Plugin,
|
||||
pub lv2_features: Arc<livi::Features>,
|
||||
pub lv2_port_list: Vec<livi::Port>,
|
||||
pub lv2_input_buffer: Vec<livi::event::LV2AtomSequence>,
|
||||
pub lv2_ui_thread: Option<JoinHandle<()>>,
|
||||
}
|
||||
|
||||
impl Lv2 {
|
||||
|
||||
pub fn new (
|
||||
jack: &Jack<'static>,
|
||||
name: &str,
|
||||
uri: &str,
|
||||
) -> Usually<Self> {
|
||||
let lv2_world = livi::World::with_load_bundle(&uri);
|
||||
let lv2_features = lv2_world.build_features(livi::FeaturesBuilder {
|
||||
min_block_length: 1,
|
||||
max_block_length: 65536,
|
||||
});
|
||||
let lv2_plugin = lv2_world.iter_plugins().nth(0)
|
||||
.unwrap_or_else(||panic!("plugin not found: {uri}"));
|
||||
Ok(Self {
|
||||
jack: jack.clone(),
|
||||
name: name.into(),
|
||||
path: Some(String::from(uri).into()),
|
||||
selected: 0,
|
||||
mapping: false,
|
||||
midi_ins: vec![],
|
||||
midi_outs: vec![],
|
||||
audio_ins: vec![],
|
||||
audio_outs: vec![],
|
||||
lv2_instance: unsafe {
|
||||
lv2_plugin
|
||||
.instantiate(lv2_features.clone(), 48000.0)
|
||||
.expect(&format!("instantiate failed: {uri}"))
|
||||
},
|
||||
lv2_port_list: lv2_plugin.ports().collect::<Vec<_>>(),
|
||||
lv2_input_buffer: Vec::with_capacity(Self::INPUT_BUFFER),
|
||||
lv2_ui_thread: None,
|
||||
lv2_world,
|
||||
lv2_features,
|
||||
lv2_plugin,
|
||||
})
|
||||
}
|
||||
|
||||
const INPUT_BUFFER: usize = 1024;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//fn jack_from_lv2 (name: &str, plugin: &::livi::Plugin) -> Usually<Jack> {
|
||||
//let counts = plugin.port_counts();
|
||||
//let mut jack = Jack::new(name)?;
|
||||
//for i in 0..counts.atom_sequence_inputs {
|
||||
//jack = jack.midi_in(&format!("midi-in-{i}"))
|
||||
//}
|
||||
//for i in 0..counts.atom_sequence_outputs {
|
||||
//jack = jack.midi_out(&format!("midi-out-{i}"));
|
||||
//}
|
||||
//for i in 0..counts.audio_inputs {
|
||||
//jack = jack.audio_in(&format!("audio-in-{i}"));
|
||||
//}
|
||||
//for i in 0..counts.audio_outputs {
|
||||
//jack = jack.audio_out(&format!("audio-out-{i}"));
|
||||
//}
|
||||
//Ok(jack)
|
||||
//}
|
||||
Loading…
Add table
Add a link
Reference in a new issue