mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
flatten modules somewhat
This commit is contained in:
parent
cb7ba855ab
commit
0779560502
29 changed files with 442 additions and 474 deletions
70
crates/tek/src/groovebox.rs
Normal file
70
crates/tek/src/groovebox.rs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
use crate::*;
|
||||
use super::*;
|
||||
use KeyCode::{Char, Delete, Tab, Up, Down, Left, Right};
|
||||
|
||||
pub struct GrooveboxTui {
|
||||
pub size: Measure<Tui>,
|
||||
pub sequencer: SequencerTui,
|
||||
pub sampler: SamplerTui,
|
||||
pub split: u16,
|
||||
pub focus: GrooveboxFocus
|
||||
}
|
||||
|
||||
from_jack!(|jack|GrooveboxTui {
|
||||
let mut sequencer = SequencerTui::try_from(jack)?;
|
||||
sequencer.status = false;
|
||||
let midi_in_1 = jack.read().unwrap().register_port("in1", MidiIn::default())?;
|
||||
let midi_out = jack.read().unwrap().register_port("out", MidiOut::default())?;
|
||||
let midi_in_2 = jack.read().unwrap().register_port("in2", MidiIn::default())?;
|
||||
let audio_in_1 = jack.read().unwrap().register_port("inL", AudioIn::default())?;
|
||||
let audio_in_2 = jack.read().unwrap().register_port("inR", AudioIn::default())?;
|
||||
let audio_out_1 = jack.read().unwrap().register_port("out1", AudioOut::default())?;
|
||||
let audio_out_2 = jack.read().unwrap().register_port("out2", AudioOut::default())?;
|
||||
Self {
|
||||
sequencer,
|
||||
sampler: SamplerTui::try_from(jack)?,
|
||||
split: 16,
|
||||
focus: GrooveboxFocus::Sequencer,
|
||||
size: Measure::new(),
|
||||
}
|
||||
});
|
||||
|
||||
pub enum GrooveboxFocus {
|
||||
Sequencer,
|
||||
Sampler
|
||||
}
|
||||
|
||||
audio!(|self:GrooveboxTui,_client,_process|Control::Continue);
|
||||
|
||||
render!(<Tui>|self:GrooveboxTui|Fill::wh(Bsp::n(
|
||||
Fixed::h(2, GrooveboxStatus::from(self)),
|
||||
Fill::h(lay!([
|
||||
Fill::h(&self.size),
|
||||
Fill::h(Bsp::s(
|
||||
Tui::min_y(20, &self.sequencer),
|
||||
Tui::min_y(20, &self.sampler),
|
||||
))
|
||||
])),
|
||||
)));
|
||||
|
||||
pub enum GrooveboxCommand {
|
||||
Sequencer(SequencerCommand),
|
||||
Sampler(SamplerCommand),
|
||||
}
|
||||
|
||||
handle!(<Tui>|self: GrooveboxTui, input|GrooveboxCommand::execute_with_state(self, input));
|
||||
|
||||
input_to_command!(GrooveboxCommand: <Tui>|state: GrooveboxTui,input|match input.event() {
|
||||
key_pat!(Up) | key_pat!(Down) | key_pat!(Left) | key_pat!(Right) |
|
||||
key_pat!(Shift-Char('L')) =>
|
||||
SamplerCommand::input_to_command(&state.sampler, input).map(Self::Sampler)?,
|
||||
_ =>
|
||||
SequencerCommand::input_to_command(&state.sequencer, input).map(Self::Sequencer)?,
|
||||
});
|
||||
|
||||
command!(|self:GrooveboxCommand,state:GrooveboxTui|match self {
|
||||
GrooveboxCommand::Sequencer(command) =>
|
||||
command.execute(&mut state.sequencer)?.map(GrooveboxCommand::Sequencer),
|
||||
GrooveboxCommand::Sampler(command) =>
|
||||
command.execute(&mut state.sampler)?.map(GrooveboxCommand::Sampler),
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue