mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: cleanup, begin reconnecting ports
This commit is contained in:
parent
e8430c373f
commit
0cca06e054
5 changed files with 41 additions and 29 deletions
|
|
@ -1,5 +1,21 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct JackPort<T: PortSpec> {
|
||||
pub port: Port<T>,
|
||||
pub connect: Vec<PortConnect>
|
||||
}
|
||||
|
||||
impl<T: PortSpec> JackPort<T> {
|
||||
//pub fn new (jack: &impl RegisterPort
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum PortConnect {
|
||||
Exact(Arc<str>),
|
||||
Wildcard(Arc<str>),
|
||||
RegExp(Arc<str>),
|
||||
}
|
||||
|
||||
/// This is a utility trait for things that may register or connect [Port]s.
|
||||
/// It contains shorthand methods to this purpose. It's implemented for
|
||||
/// `Arc<RwLock<JackConnection>>` for terse port registration in the
|
||||
|
|
|
|||
18
src/main.rs
18
src/main.rs
|
|
@ -114,9 +114,9 @@ pub fn main () -> Usually<()> {
|
|||
None, Some(ItemColor::random().into())
|
||||
)));
|
||||
let midi_in = jack.read().unwrap().register_port("i", MidiIn::default())?;
|
||||
connect_from(&jack, &midi_in, &midi_from)?;
|
||||
connect_from(jack, &midi_in, &midi_from)?;
|
||||
let midi_out = jack.read().unwrap().register_port("o", MidiOut::default())?;
|
||||
connect_to(&jack, &midi_out, &midi_to)?;
|
||||
connect_to(jack, &midi_out, &midi_to)?;
|
||||
Sequencer {
|
||||
_jack: jack.clone(),
|
||||
pool: PoolModel::from(&phrase),
|
||||
|
|
@ -156,9 +156,13 @@ pub fn main () -> Usually<()> {
|
|||
TekMode::Groovebox {
|
||||
midi_from, midi_to, l_from, r_from, l_to, r_to, ..
|
||||
} => engine.run(&jack.activate_with(|jack|Ok({
|
||||
let ppq = 96;
|
||||
let phrase = Arc::new(RwLock::new(MidiClip::new(
|
||||
"Clip", true, 4 * player.clock.timebase.ppq.get() as usize,
|
||||
None, Some(ItemColor::random().into())
|
||||
"Clip",
|
||||
true,
|
||||
4 * ppq,
|
||||
None,
|
||||
Some(ItemColor::random().into())
|
||||
)));
|
||||
let mut player = MidiPlayer::new(jack, &"sequencer", Some(&phrase),
|
||||
&midi_from,
|
||||
|
|
@ -166,9 +170,9 @@ pub fn main () -> Usually<()> {
|
|||
)?;
|
||||
player.play_phrase = Some((Moment::zero(&player.clock.timebase), Some(phrase.clone())));
|
||||
let sampler = Sampler::new(jack, &"sampler",
|
||||
midi_from,
|
||||
&[l_from, r_from],
|
||||
&[l_to, r_to ],
|
||||
&midi_from,
|
||||
&[&l_from, &r_from],
|
||||
&[&l_to, &r_to ],
|
||||
)?;
|
||||
jack.read().unwrap().client().connect_ports(
|
||||
&player.midi_outs[0],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
use crate::*;
|
||||
|
||||
pub fn buffer_update (buf: &mut Buffer, area: [u16;4], callback: &impl Fn(&mut Cell, u16, u16)) {
|
||||
for row in 0..area.h() {
|
||||
let y = area.y() + row;
|
||||
for col in 0..area.w() {
|
||||
let x = area.x() + col;
|
||||
if x < buf.area.width && y < buf.area.height {
|
||||
callback(buf.get_mut(x, y), col, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct BigBuffer {
|
||||
pub width: usize,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ use crate::*;
|
|||
|
||||
pub struct Tui {
|
||||
pub exited: Arc<AtomicBool>,
|
||||
pub buffer: Buffer,
|
||||
pub backend: CrosstermBackend<Stdout>,
|
||||
pub area: [u16;4], // FIXME auto resize
|
||||
pub buffer: Buffer,
|
||||
pub area: [u16;4],
|
||||
}
|
||||
|
||||
impl Tui {
|
||||
|
|
|
|||
|
|
@ -79,23 +79,3 @@ pub fn buffer_update (buf: &mut Buffer, area: [u16;4], callback: &impl Fn(&mut C
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//impl Area<u16> for Rect {
|
||||
//fn x (&self) -> u16 { self.x }
|
||||
//fn y (&self) -> u16 { self.y }
|
||||
//fn w (&self) -> u16 { self.width }
|
||||
//fn h (&self) -> u16 { self.height }
|
||||
//}
|
||||
|
||||
pub fn half_block (lower: bool, upper: bool) -> Option<char> {
|
||||
match (lower, upper) {
|
||||
(true, true) => Some('█'),
|
||||
(true, false) => Some('▄'),
|
||||
(false, true) => Some('▀'),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
//impl<T: Content<TuiOut>> Render<TuiOut> for T {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue