mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: vst2 host?
This commit is contained in:
parent
228805d30d
commit
4b0055a21c
7 changed files with 151 additions and 42 deletions
|
|
@ -2,14 +2,16 @@ use crate::prelude::*;
|
|||
|
||||
pub struct Chain {
|
||||
name: String,
|
||||
devices: Vec<Box<dyn Device>>
|
||||
devices: Vec<Box<dyn Device>>,
|
||||
focused: usize,
|
||||
}
|
||||
|
||||
impl Chain {
|
||||
pub fn new (name: &str, devices: Vec<Box<dyn Device>>) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
||||
Ok(DynamicDevice::new(render, handle, process, Self {
|
||||
name: name.into(),
|
||||
devices
|
||||
devices,
|
||||
focused: 0
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
@ -28,18 +30,17 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
|||
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + 2, y, "Input...", Style::default().dim());
|
||||
let mut x = 0u16;
|
||||
y = y + 1;
|
||||
for device in state.devices.iter() {
|
||||
let result = device.render(buf, Rect {
|
||||
x: area.x,
|
||||
y: area.y + y,
|
||||
y,
|
||||
width: area.width,
|
||||
height: area.height.saturating_sub(y)
|
||||
height: 21//area.height.saturating_sub(y)
|
||||
})?;
|
||||
//buf.set_string(area.x, y, format!("{y}---TOP---+{h}"), Style::default().red());
|
||||
//let result = Rect { x: 0, y: 0, width: result.width, height: 21 };
|
||||
x = x.max(result.width);
|
||||
y = y + result.height;
|
||||
y = y + 1;
|
||||
//y = y + 1;
|
||||
buf.set_string(area.x, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + area.width - 1, y, "│", Style::default().black());
|
||||
buf.set_string(area.x + 2, y, " Patch in ┐ │ └ Patch out", Style::default().dim());
|
||||
|
|
@ -48,7 +49,12 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
|||
//buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
|
||||
//buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
|
||||
}
|
||||
Ok(Rect { x: area.x, y: area.y, width: x, height: y })
|
||||
Ok(draw_box(buf, Rect {
|
||||
x: area.x,
|
||||
y: area.y,
|
||||
width: area.width,
|
||||
height: y - area.y,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn handle (_: &mut Chain, _: &AppEvent) -> Usually<bool> {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,28 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub struct Plugin {
|
||||
name: String
|
||||
name: String,
|
||||
plugin: Option<::vst::host::PluginInstance>
|
||||
}
|
||||
|
||||
impl Plugin {
|
||||
pub fn new (name: &str) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
||||
Ok(DynamicDevice::new(render, handle, process, Self {
|
||||
name: name.into()
|
||||
}))
|
||||
let device = DynamicDevice::new(render, handle, process, Self {
|
||||
name: name.into(),
|
||||
plugin: None,
|
||||
});
|
||||
let mut loader = ::vst::host::PluginLoader::load(
|
||||
&std::path::Path::new("/nix/store/ij3sz7nqg5l7v2dygdvzy3w6cj62bd6r-helm-0.9.0/lib/lxvst/helm.so"),
|
||||
device.state.clone()
|
||||
)?;
|
||||
let plugin = loader.instance()?;
|
||||
device.state.lock().unwrap().plugin = Some(plugin);
|
||||
Ok(device)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::vst::host::Host for Plugin {}
|
||||
|
||||
pub fn process (_: &mut Plugin, _: &Client, _: &ProcessScope) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,47 +4,47 @@ use ratatui::style::Stylize;
|
|||
type Sequence = std::collections::BTreeMap<u32, Vec<::midly::MidiMessage>>;
|
||||
|
||||
pub struct Sequencer {
|
||||
name: String,
|
||||
name: String,
|
||||
/// JACK transport handle.
|
||||
transport: ::jack::Transport,
|
||||
transport: ::jack::Transport,
|
||||
/// Holds info about tempo
|
||||
timebase: Arc<Timebase>,
|
||||
timebase: Arc<Timebase>,
|
||||
/// Sequencer resolution, e.g. 16 steps per beat.
|
||||
resolution: usize,
|
||||
resolution: usize,
|
||||
/// Steps in sequence, e.g. 64 16ths = 4 beat loop.
|
||||
steps: usize,
|
||||
steps: usize,
|
||||
|
||||
/// JACK MIDI input port that will be created.
|
||||
input_port: Port<MidiIn>,
|
||||
input_port: Port<MidiIn>,
|
||||
/// Port name patterns to connect to.
|
||||
input_connect: Vec<String>,
|
||||
input_connect: Vec<String>,
|
||||
/// Play input through output.
|
||||
monitoring: bool,
|
||||
monitoring: bool,
|
||||
/// Red keys on piano roll.
|
||||
notes_on: Vec<bool>,
|
||||
notes_on: Vec<bool>,
|
||||
/// Write input to sequence.
|
||||
recording: bool,
|
||||
recording: bool,
|
||||
/// Map: tick -> MIDI events at tick
|
||||
sequence: Sequence,
|
||||
sequence: Sequence,
|
||||
/// Don't delete when recording.
|
||||
overdub: bool,
|
||||
overdub: bool,
|
||||
/// Play sequence to output.
|
||||
playing: bool,
|
||||
playing: bool,
|
||||
/// JACK MIDI output port that will be created.
|
||||
output_port: Port<MidiOut>,
|
||||
output_port: Port<MidiOut>,
|
||||
/// Port name patterns to connect to.
|
||||
output_connect: Vec<String>,
|
||||
output_connect: Vec<String>,
|
||||
|
||||
/// Display mode
|
||||
mode: SequencerView,
|
||||
mode: SequencerView,
|
||||
/// Range of notes to display
|
||||
note_axis: (u16, u16),
|
||||
note_axis: (u16, u16),
|
||||
/// Position of cursor within note range
|
||||
note_cursor: u16,
|
||||
note_cursor: u16,
|
||||
/// Range of time steps to display
|
||||
time_axis: (u16, u16),
|
||||
time_axis: (u16, u16),
|
||||
/// Position of cursor within time range
|
||||
time_cursor: u16,
|
||||
time_cursor: u16,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ impl Device for Rows {
|
|||
true
|
||||
},
|
||||
Event::Key(KeyEvent { code: KeyCode::Enter, .. }) => {
|
||||
self.focused = false;
|
||||
self.focused = true;
|
||||
self.items[self.focus].handle(&AppEvent::Focus)?;
|
||||
true
|
||||
},
|
||||
Event::Key(KeyEvent { code: KeyCode::Esc, .. }) => {
|
||||
self.focused = true;
|
||||
self.focused = false;
|
||||
self.items[self.focus].handle(&AppEvent::Blur)?;
|
||||
true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ fn main () -> Result<(), Box<dyn Error>> {
|
|||
crate::device::run(Rows::new(false, vec![
|
||||
Box::new(transport),
|
||||
Box::new(Columns::new(false, vec![
|
||||
Box::new(Sequencer::new("Melody#000", &timebase)?),
|
||||
Box::new(Chain::new("Chain#0000", vec![
|
||||
Box::new(Sequencer::new("Melody#000", &timebase)?),
|
||||
Box::new(Plugin::new("Plugin#000")?),
|
||||
])?),
|
||||
Box::new(Sequencer::new("Melody#001", &timebase)?),
|
||||
Box::new(Sequencer::new("Rhythm#000", &timebase)?),
|
||||
])),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue