mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
panic hook; two sequencers
This commit is contained in:
parent
0ee9e58dc7
commit
abee6cc2c8
16 changed files with 927 additions and 828 deletions
129
src/main.rs
129
src/main.rs
|
|
@ -43,7 +43,7 @@ fn run_one (command: &cli::Command) -> Result<(), Box<dyn Error>> {
|
|||
sampler::Sampler::new()?,
|
||||
),
|
||||
cli::Command::Sequencer => engine.run(
|
||||
sequencer::Sequencer::new()?,
|
||||
sequencer::Sequencer::new(Some("sequencer"))?,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
@ -54,7 +54,10 @@ fn run_all () -> Result<(), Box<dyn Error>> {
|
|||
exited: false,
|
||||
mode: Mode::Sequencer,
|
||||
transport: transport::Transport::new(engine.jack_client.as_client())?,
|
||||
sequencer: sequencer::Sequencer::new()?,
|
||||
sequencers: vec![
|
||||
sequencer::Sequencer::new(Some("Melody#000"))?,
|
||||
sequencer::Sequencer::new(Some("Rhythm#000"))?,
|
||||
],
|
||||
mixer: mixer::Mixer::new()?,
|
||||
looper: looper::Looper::new()?,
|
||||
sampler: sampler::Sampler::new()?,
|
||||
|
|
@ -63,14 +66,14 @@ fn run_all () -> Result<(), Box<dyn Error>> {
|
|||
}
|
||||
|
||||
struct App {
|
||||
exited: bool,
|
||||
mode: Mode,
|
||||
transport: crate::transport::Transport,
|
||||
mixer: crate::mixer::Mixer,
|
||||
looper: crate::looper::Looper,
|
||||
sampler: crate::sampler::Sampler,
|
||||
sequencer: crate::sequencer::Sequencer,
|
||||
actions: Vec<(&'static str, &'static str)>
|
||||
exited: bool,
|
||||
mode: Mode,
|
||||
transport: crate::transport::Transport,
|
||||
mixer: crate::mixer::Mixer,
|
||||
looper: crate::looper::Looper,
|
||||
sampler: crate::sampler::Sampler,
|
||||
sequencers: Vec<crate::sequencer::Sequencer>,
|
||||
actions: Vec<(&'static str, &'static str)>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
|
|
@ -94,46 +97,74 @@ impl Exitable for App {
|
|||
impl WidgetRef for App {
|
||||
fn render_ref (&self, area: Rect, buffer: &mut Buffer) {
|
||||
use ratatui::{widgets::*, style::Stylize};
|
||||
let column_constraints = vec![
|
||||
Constraint::Percentage(28),
|
||||
Constraint::Percentage(72),
|
||||
];
|
||||
let row_constraints = vec![
|
||||
Constraint::Length(4),
|
||||
Constraint::Length(14),
|
||||
Constraint::Length(10),
|
||||
Constraint::Length(10),
|
||||
Constraint::Length(10),
|
||||
];
|
||||
let cols = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints(column_constraints)
|
||||
let areas = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
Constraint::Length(4),
|
||||
Constraint::Min(16),
|
||||
Constraint::Min(16),
|
||||
].clone())
|
||||
.split(area);
|
||||
let side = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(row_constraints.clone())
|
||||
.split(cols[0]);
|
||||
let main = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(row_constraints)
|
||||
.split(cols[1]);
|
||||
self.transport.render(area, buffer);
|
||||
self.sequencers[0].render(areas[1], buffer);
|
||||
self.sequencers[1].render(areas[2], buffer);
|
||||
|
||||
Line::from(" Transport").render(side[0], buffer);
|
||||
self.transport.render(main[0].inner(&Margin {
|
||||
vertical: 0,
|
||||
horizontal: 1,
|
||||
}), buffer);
|
||||
buffer.set_string(
|
||||
area.x, main[1].y-1, "─".repeat(area.width as usize), Style::default().black().dim()
|
||||
);
|
||||
Line::from(" Piano roll").render(side[1], buffer);
|
||||
self.sequencer.render(main[1].inner(&Margin {
|
||||
vertical: 0,
|
||||
horizontal: 1,
|
||||
}), buffer);
|
||||
buffer.set_string(
|
||||
area.x, main[2].y+1, "─".repeat(area.width as usize), Style::default().black().dim()
|
||||
);
|
||||
//buffer.set_string(
|
||||
//area.x, area.y + 5,
|
||||
//format!(" [ ] Melody#000 │1.1 │1.2 │1.3 │1.4 │ → None "),
|
||||
//Style::default()
|
||||
//);
|
||||
//buffer.set_string(
|
||||
//area.x, area.y + 6,
|
||||
//format!(" Variation: │A │B │C │D │E │F │G │H │"),
|
||||
//Style::default()
|
||||
//);
|
||||
//buffer.set_string(
|
||||
//area.x, area.y + 7,
|
||||
//format!(" [x] Chain 𝄆 A A B A 𝄇"),
|
||||
//Style::default()
|
||||
//);
|
||||
|
||||
//buffer.set_string(
|
||||
//area.x, area.y,
|
||||
//format!("│"),
|
||||
//Style::default().black()
|
||||
//);
|
||||
//buffer.set_string(
|
||||
//area.x + area.width - 1, area.y,
|
||||
//format!("│"),
|
||||
//Style::default().black()
|
||||
//);
|
||||
//buffer.set_string(
|
||||
//area.x, area.y + 1,
|
||||
//format!("╰{}╯", "─".repeat((area.width - 2) as usize)),
|
||||
//Style::default().black()
|
||||
//);
|
||||
|
||||
////Paragraph::new("|Project: The Witty Gerbils - Sha Na Na\n|Rewind |Play |BPM▐▔▔▔▔▔▔▔▔▔▔▔▔▔▔▌\n▐ ⯈ Play/Pause ▌\n▐▁▁▁▁▁▁▁▁▁▁▁▁▁▁▌")
|
||||
//Paragraph::new("|Project: The Witty Gerbils - Sha Na Na\n|Rewind |Play |Beat 1.1.0 |BPM 113.000 |Time: 123.456 |Rate: 44100Hz |Frame: 2000000000")
|
||||
//.render(transport_area, buffer);
|
||||
|
||||
//self.transport.render(main[0].inner(&Margin {
|
||||
//vertical: 0,
|
||||
//horizontal: 1,
|
||||
//}), buffer);
|
||||
//buffer.set_string(
|
||||
//area.x, main[1].y-1,
|
||||
//format!("╭{}╮", "─".repeat((area.width - 2) as usize)),
|
||||
//Style::default().black()
|
||||
//);
|
||||
//Paragraph::new("│|Melody #000\n│\n│|Port:\n│|Channel:\n│\n│\n│\n│\n│\n│\n│\n│\n│\n│|Variation:")
|
||||
//.render(side[1], buffer);
|
||||
//self.sequencer.render(main[1].inner(&Margin {
|
||||
//vertical: 0,
|
||||
//horizontal: 1,
|
||||
//}), buffer);
|
||||
//buffer.set_string(
|
||||
//area.x, main[2].y+1,
|
||||
//format!("╰{}╯", "─".repeat((area.width - 2) as usize)),
|
||||
//Style::default().black()
|
||||
//);
|
||||
|
||||
//Block::default()
|
||||
//.title("Sampler")
|
||||
|
|
@ -243,7 +274,7 @@ impl HandleInput for App {
|
|||
.handle(&event)?,
|
||||
Mode::Sampler => self.sampler
|
||||
.handle(&event)?,
|
||||
Mode::Sequencer => self.sequencer
|
||||
Mode::Sequencer => self.sequencers[0]
|
||||
.handle(&event)?,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue