mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
group devices
This commit is contained in:
parent
60627ac3e5
commit
5afed6f055
8 changed files with 147 additions and 267 deletions
44
src/device.rs
Normal file
44
src/device.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
pub mod transport;
|
||||||
|
pub mod sequencer;
|
||||||
|
pub mod sampler;
|
||||||
|
pub mod mixer;
|
||||||
|
pub mod looper;
|
||||||
|
|
||||||
|
use crate::prelude::*;
|
||||||
|
use self::transport::*;
|
||||||
|
use self::sequencer::*;
|
||||||
|
use self::sampler::*;
|
||||||
|
use self::mixer::*;
|
||||||
|
use self::looper::*;
|
||||||
|
|
||||||
|
pub enum Device {
|
||||||
|
Transport(self::transport::Transport),
|
||||||
|
Sequencer(self::sequencer::Sequencer),
|
||||||
|
Sampler(self::sampler::Sampler),
|
||||||
|
Mixer(self::mixer::Mixer),
|
||||||
|
Looper(self::looper::Looper),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WidgetRef for Device {
|
||||||
|
fn render_ref (&self, area: Rect, buf: &mut Buffer) {
|
||||||
|
match self {
|
||||||
|
Self::Transport(device) => device.render(area, buf),
|
||||||
|
Self::Sequencer(device) => device.render(area, buf),
|
||||||
|
Self::Sampler(device) => device.render(area, buf),
|
||||||
|
Self::Mixer(device) => device.render(area, buf),
|
||||||
|
Self::Looper(device) => device.render(area, buf),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HandleInput for Device {
|
||||||
|
fn handle (&mut self, event: &crate::engine::Event) -> Result<(), Box<dyn Error>> {
|
||||||
|
match self {
|
||||||
|
Self::Transport(device) => device.handle(event),
|
||||||
|
Self::Sequencer(device) => device.handle(event),
|
||||||
|
Self::Sampler(device) => device.handle(event),
|
||||||
|
Self::Mixer(device) => device.handle(event),
|
||||||
|
Self::Looper(device) => device.handle(event),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,7 +17,7 @@ impl Sampler {
|
||||||
pub fn new () -> Result<Self, Box<dyn Error>> {
|
pub fn new () -> Result<Self, Box<dyn Error>> {
|
||||||
let exited = Arc::new(AtomicBool::new(false));
|
let exited = Arc::new(AtomicBool::new(false));
|
||||||
let (client, status) = Client::new(
|
let (client, status) = Client::new(
|
||||||
"blinkenlive-sampler",
|
"Sampler#000",
|
||||||
ClientOptions::NO_START_SERVER
|
ClientOptions::NO_START_SERVER
|
||||||
)?;
|
)?;
|
||||||
let samples = vec![
|
let samples = vec![
|
||||||
|
|
@ -271,4 +271,3 @@ impl NotificationHandler for Notifications {
|
||||||
Control::Continue
|
Control::Continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9,6 +9,7 @@ pub const ACTIONS: [(&'static str, &'static str);4] = [
|
||||||
];
|
];
|
||||||
|
|
||||||
pub struct Sequencer {
|
pub struct Sequencer {
|
||||||
|
name: Arc<str>,
|
||||||
exited: Arc<AtomicBool>,
|
exited: Arc<AtomicBool>,
|
||||||
sequence: Arc<Mutex<Vec<Vec<Option<Event>>>>>,
|
sequence: Arc<Mutex<Vec<Vec<Option<Event>>>>>,
|
||||||
cursor: (u16, u16, u16),
|
cursor: (u16, u16, u16),
|
||||||
|
|
@ -26,7 +27,8 @@ impl Sequencer {
|
||||||
|
|
||||||
pub fn new (name: Option<&str>) -> Result<Self, Box<dyn Error>> {
|
pub fn new (name: Option<&str>) -> Result<Self, Box<dyn Error>> {
|
||||||
let exited = Arc::new(AtomicBool::new(false));
|
let exited = Arc::new(AtomicBool::new(false));
|
||||||
let (client, _status) = Client::new(name.unwrap_or("sequencer"), ClientOptions::NO_START_SERVER)?;
|
let name = name.unwrap_or("sequencer");
|
||||||
|
let (client, _status) = Client::new(name, ClientOptions::NO_START_SERVER)?;
|
||||||
let mut port = client.register_port("sequence", ::jack::MidiOut::default())?;
|
let mut port = client.register_port("sequence", ::jack::MidiOut::default())?;
|
||||||
let sequence: Arc<Mutex<Vec<Vec<Option<Event>>>>> = Arc::new(Mutex::new(vec![vec![None;64];128]));
|
let sequence: Arc<Mutex<Vec<Vec<Option<Event>>>>> = Arc::new(Mutex::new(vec![vec![None;64];128]));
|
||||||
let beats = 4;
|
let beats = 4;
|
||||||
|
|
@ -49,6 +51,7 @@ impl Sequencer {
|
||||||
frame_steps[*frame] = Some(index);
|
frame_steps[*frame] = Some(index);
|
||||||
}
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
name: name.into(),
|
||||||
exited: exited.clone(),
|
exited: exited.clone(),
|
||||||
sequence: sequence.clone(),
|
sequence: sequence.clone(),
|
||||||
cursor: (11, 0, 0),
|
cursor: (11, 0, 0),
|
||||||
|
|
@ -184,21 +187,18 @@ const KEYS: [&'static str; 6] = [
|
||||||
|
|
||||||
impl WidgetRef for Sequencer {
|
impl WidgetRef for Sequencer {
|
||||||
fn render_ref (&self, area: Rect, buf: &mut Buffer) {
|
fn render_ref (&self, area: Rect, buf: &mut Buffer) {
|
||||||
|
draw_leaf(buf, area, 1, 0, &format!("{} ", &self.name));
|
||||||
|
draw_leaf(buf, area, 3, 0, "Channel: 01");
|
||||||
|
draw_leaf(buf, area, 5, 0, "Zoom: 1/64");
|
||||||
|
draw_leaf(buf, area, 7, 0, "Rate: 1/1");
|
||||||
|
|
||||||
|
draw_leaf(buf, area, 10, 0, "Inputs: ");
|
||||||
|
draw_leaf(buf, area, 13, 0, "Outputs: ");
|
||||||
{
|
{
|
||||||
let mut area = area.clone();
|
let mut area = area.clone();
|
||||||
area.height = 18;
|
area.height = 18;
|
||||||
draw_box(buf, area);
|
draw_box(buf, area);
|
||||||
}
|
}
|
||||||
draw_leaf(buf, area, 3, 0, "Channel: 01");
|
|
||||||
draw_leaf(buf, area, 5, 0, "Zoom: 1/64");
|
|
||||||
draw_leaf(buf, area, 7, 0, "Rate: 1/1");
|
|
||||||
{
|
|
||||||
let title = "(no inputs) -> Melody#000 -> (no outputs)";
|
|
||||||
let mut area = area.clone();
|
|
||||||
area.x = (area.width - title.len() as u16) / 2;
|
|
||||||
area.width = title.len() as u16;
|
|
||||||
draw_leaf(buf, area, 1, 0, title);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
let mut area = area.inner(&Margin { horizontal: 1, vertical: 3, });
|
let mut area = area.inner(&Margin { horizontal: 1, vertical: 3, });
|
||||||
area.x = area.x + 14;
|
area.x = area.x + 14;
|
||||||
|
|
@ -212,10 +212,10 @@ impl WidgetRef for Sequencer {
|
||||||
fn draw_sequence_header (
|
fn draw_sequence_header (
|
||||||
area: Rect, buf: &mut Buffer
|
area: Rect, buf: &mut Buffer
|
||||||
) {
|
) {
|
||||||
buf.set_string(area.x + 3, area.y, "|1.1.", Style::default().dim());
|
buf.set_string(area.x + 3, area.y, "╭1.1.", Style::default().dim());
|
||||||
buf.set_string(area.x + 3 + 16, area.y, "|1.2.", Style::default().dim());
|
buf.set_string(area.x + 3 + 16, area.y, "╭1.2.", Style::default().dim());
|
||||||
buf.set_string(area.x + 3 + 32, area.y, "|1.3.", Style::default().dim());
|
buf.set_string(area.x + 3 + 32, area.y, "╭1.3.", Style::default().dim());
|
||||||
buf.set_string(area.x + 3 + 48, area.y, "|1.4.", Style::default().dim());
|
buf.set_string(area.x + 3 + 48, area.y, "╭1.4.", Style::default().dim());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_sequence_keys (
|
fn draw_sequence_keys (
|
||||||
|
|
@ -224,11 +224,10 @@ fn draw_sequence_keys (
|
||||||
transport: &::jack::TransportStatePosition,
|
transport: &::jack::TransportStatePosition,
|
||||||
sequence: &Arc<Mutex<Vec<Vec<Option<self::Event>>>>>
|
sequence: &Arc<Mutex<Vec<Vec<Option<self::Event>>>>>
|
||||||
) {
|
) {
|
||||||
buf.set_string(area.x + 2, area.y, "╭", Style::default().black());
|
//buf.set_string(area.x + 2, area.y, "╭", Style::default().dim());
|
||||||
buf.set_string(area.x + 2, area.y + 13, "╰", Style::default().black());
|
//buf.set_string(area.x + 2, area.y + 13, "╰", Style::default().dim());
|
||||||
buf.set_string(area.x + 2 + 65, area.y, "╮", Style::default().black());
|
buf.set_string(area.x + 2 + 65, area.y, "╮", Style::default().dim());
|
||||||
buf.set_string(area.x + 2 + 65, area.y + 13, "╯", Style::default().black());
|
buf.set_string(area.x + 2 + 65, area.y + 13, "╯", Style::default().dim());
|
||||||
//let transport = state.transport.query()?;
|
|
||||||
let frame = transport.pos.frame();
|
let frame = transport.pos.frame();
|
||||||
let rate = transport.pos.frame_rate().unwrap();
|
let rate = transport.pos.frame_rate().unwrap();
|
||||||
let second = (frame as f64) / (rate as f64);
|
let second = (frame as f64) / (rate as f64);
|
||||||
|
|
@ -240,6 +239,9 @@ fn draw_sequence_keys (
|
||||||
let beat = beats as u32 % div as u32 + 1;
|
let beat = beats as u32 % div as u32 + 1;
|
||||||
let beat_sub = beats % 1.0;
|
let beat_sub = beats % 1.0;
|
||||||
let sequence = sequence.lock().unwrap();
|
let sequence = sequence.lock().unwrap();
|
||||||
|
buf.set_string(
|
||||||
|
area.x + area.width - 25, area.y - 2, format!("{bars:04}:{beat:02}.{:02}", (beat_sub * 16.0) as u32), Style::default()
|
||||||
|
);
|
||||||
for key in 0..12 {
|
for key in 0..12 {
|
||||||
buf.set_string(area.x, area.y + 1 + key, KEYS[(key % 6) as usize],
|
buf.set_string(area.x, area.y + 1 + key, KEYS[(key % 6) as usize],
|
||||||
Style::default().black());
|
Style::default().black());
|
||||||
|
|
@ -268,10 +270,10 @@ fn draw_sequence_keys (
|
||||||
},
|
},
|
||||||
(false, false) => if step % 16 == 0 {
|
(false, false) => if step % 16 == 0 {
|
||||||
buf.set_string(area.x + 3 + step as u16, area.y + 1 + key, "┊",
|
buf.set_string(area.x + 3 + step as u16, area.y + 1 + key, "┊",
|
||||||
Style::default().black().dim().bg(bg))
|
Style::default().black().bg(bg))
|
||||||
} else {
|
} else {
|
||||||
buf.set_string(area.x + 3 + step as u16, area.y + 1 + key, "·",
|
buf.set_string(area.x + 3 + step as u16, area.y + 1 + key, "·",
|
||||||
Style::default().black().dim().bg(bg))
|
Style::default().black().bg(bg))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
261
src/main.rs
261
src/main.rs
|
|
@ -6,13 +6,9 @@ use clap::{Parser, Subcommand};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
pub mod cli;
|
pub mod cli;
|
||||||
|
pub mod device;
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
pub mod engine;
|
pub mod engine;
|
||||||
pub mod transport;
|
|
||||||
pub mod mixer;
|
|
||||||
pub mod looper;
|
|
||||||
pub mod sampler;
|
|
||||||
pub mod sequencer;
|
|
||||||
pub mod render;
|
pub mod render;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
|
||||||
|
|
@ -23,60 +19,57 @@ fn main () -> Result<(), Box<dyn Error>> {
|
||||||
let cli = cli::Cli::parse();
|
let cli = cli::Cli::parse();
|
||||||
let xdg = microxdg::XdgApp::new("dawdle")?;
|
let xdg = microxdg::XdgApp::new("dawdle")?;
|
||||||
crate::config::create_dirs(&xdg)?;
|
crate::config::create_dirs(&xdg)?;
|
||||||
if let Some(command) = cli.command {
|
|
||||||
run_one(&command)
|
|
||||||
} else {
|
|
||||||
run_all()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_one (command: &cli::Command) -> Result<(), Box<dyn Error>> {
|
|
||||||
let mut engine = crate::engine::Engine::new(None)?;
|
let mut engine = crate::engine::Engine::new(None)?;
|
||||||
match command {
|
match cli.command {
|
||||||
cli::Command::Transport => engine.run(
|
Some(cli::Command::Transport) => engine.run(
|
||||||
transport::Transport::new(engine.jack_client.as_client())?,
|
crate::device::transport::Transport::new(engine.jack_client.as_client())?,
|
||||||
),
|
),
|
||||||
cli::Command::Mixer => engine.run(
|
Some(cli::Command::Mixer) => engine.run(
|
||||||
mixer::Mixer::new()?,
|
crate::device::mixer::Mixer::new()?,
|
||||||
),
|
),
|
||||||
cli::Command::Looper => engine.run(
|
Some(cli::Command::Looper) => engine.run(
|
||||||
looper::Looper::new()?,
|
crate::device::looper::Looper::new()?,
|
||||||
),
|
),
|
||||||
cli::Command::Sampler => engine.run(
|
Some(cli::Command::Sampler) => engine.run(
|
||||||
sampler::Sampler::new()?,
|
crate::device::sampler::Sampler::new()?,
|
||||||
),
|
),
|
||||||
cli::Command::Sequencer => engine.run(
|
Some(cli::Command::Sequencer) => engine.run(
|
||||||
sequencer::Sequencer::new(Some("sequencer"))?,
|
crate::device::sequencer::Sequencer::new(Some("Sequencer"))?,
|
||||||
),
|
),
|
||||||
|
None => engine.run(App {
|
||||||
|
exited: false,
|
||||||
|
mode: Mode::Sequencer,
|
||||||
|
transport: crate::device::transport::Transport::new(
|
||||||
|
engine.jack_client.as_client()
|
||||||
|
)?,
|
||||||
|
focus: 0,
|
||||||
|
devices: vec![
|
||||||
|
crate::device::Device::Sequencer(
|
||||||
|
crate::device::sequencer::Sequencer::new(Some("Melody#000"))?
|
||||||
|
),
|
||||||
|
crate::device::Device::Sequencer(
|
||||||
|
crate::device::sequencer::Sequencer::new(Some("Rhythm#000"))?
|
||||||
|
),
|
||||||
|
crate::device::Device::Sampler(
|
||||||
|
crate::device::sampler::Sampler::new()?
|
||||||
|
),
|
||||||
|
crate::device::Device::Mixer(
|
||||||
|
crate::device::mixer::Mixer::new()?
|
||||||
|
),
|
||||||
|
crate::device::Device::Looper(
|
||||||
|
crate::device::looper::Looper::new()?
|
||||||
|
),
|
||||||
|
]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_all () -> Result<(), Box<dyn Error>> {
|
|
||||||
let mut engine = crate::engine::Engine::new(None)?;
|
|
||||||
engine.run(App {
|
|
||||||
exited: false,
|
|
||||||
mode: Mode::Sequencer,
|
|
||||||
transport: transport::Transport::new(engine.jack_client.as_client())?,
|
|
||||||
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()?,
|
|
||||||
actions: vec![],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
struct App {
|
struct App {
|
||||||
exited: bool,
|
exited: bool,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
transport: crate::transport::Transport,
|
transport: crate::device::transport::Transport,
|
||||||
mixer: crate::mixer::Mixer,
|
focus: usize,
|
||||||
looper: crate::looper::Looper,
|
devices: Vec<crate::device::Device>,
|
||||||
sampler: crate::sampler::Sampler,
|
|
||||||
sequencers: Vec<crate::sequencer::Sequencer>,
|
|
||||||
actions: Vec<(&'static str, &'static str)>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
|
|
@ -99,117 +92,23 @@ impl Exitable for App {
|
||||||
|
|
||||||
impl WidgetRef for App {
|
impl WidgetRef for App {
|
||||||
fn render_ref (&self, area: Rect, buffer: &mut Buffer) {
|
fn render_ref (&self, area: Rect, buffer: &mut Buffer) {
|
||||||
use ratatui::{widgets::*, style::Stylize};
|
use ratatui::style::Stylize;
|
||||||
|
let mut constraints = vec![
|
||||||
|
Constraint::Length(4),
|
||||||
|
Constraint::Max(18),
|
||||||
|
Constraint::Max(18),
|
||||||
|
Constraint::Max(0),
|
||||||
|
Constraint::Max(0),
|
||||||
|
Constraint::Max(0),
|
||||||
|
];
|
||||||
let areas = Layout::default()
|
let areas = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints([
|
.constraints(&constraints)
|
||||||
Constraint::Length(4),
|
|
||||||
Constraint::Max(18),
|
|
||||||
Constraint::Max(18),
|
|
||||||
].clone())
|
|
||||||
.split(area);
|
.split(area);
|
||||||
self.transport.render(area, buffer);
|
self.transport.render(areas[0], buffer);
|
||||||
self.sequencers[0].render(areas[1], buffer);
|
for (index, device) in self.devices.iter().enumerate() {
|
||||||
self.sequencers[1].render(areas[2], buffer);
|
device.render(areas[index + 1], buffer);
|
||||||
|
}
|
||||||
//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")
|
|
||||||
//.borders(Borders::ALL)
|
|
||||||
//.render(rows[2], buffer);
|
|
||||||
|
|
||||||
//Block::default()
|
|
||||||
//.title("Mixer")
|
|
||||||
//.borders(Borders::ALL)
|
|
||||||
//.render(rows[3], buffer);
|
|
||||||
|
|
||||||
//Block::default()
|
|
||||||
//.title("Looper")
|
|
||||||
//.borders(Borders::ALL)
|
|
||||||
//.render(rows[4], buffer);
|
|
||||||
|
|
||||||
|
|
||||||
//let mut offset = (0, 0);
|
|
||||||
//let (w, h) = render::render_toolbar_vertical(stdout, (offset.0, offset.1 + 1), &actions)?;
|
|
||||||
//offset.0 = offset.0 + 20;
|
|
||||||
|
|
||||||
//transport::render(&mut state.transport, stdout, (offset.0 + 1, 1))?;
|
|
||||||
//render::render_box(stdout, Some("Transport"), offset.0, 0, 70, 4,
|
|
||||||
//state.mode == Mode::Transport)?;
|
|
||||||
|
|
||||||
//sequencer::render(&mut state.sequencer, stdout, (offset.0 + 1, 3))?;
|
|
||||||
//render::render_box(stdout, Some("Sequencer"), offset.0, 5, 70, 6,
|
|
||||||
//state.mode == Mode::Sequencer)?;
|
|
||||||
|
|
||||||
//sampler::render(&mut state.sampler, stdout, (offset.0 + 1, 10))?;
|
|
||||||
//render::render_box(stdout, Some("Sampler"), offset.0, 12, 70, 4,
|
|
||||||
//state.mode == Mode::Sampler)?;
|
|
||||||
|
|
||||||
//mixer::render(&mut state.mixer, stdout, (offset.0 + 1, 18))?;
|
|
||||||
//render::render_box(stdout, Some("Mixer"), offset.0, 17, 70, 9,
|
|
||||||
//state.mode == Mode::Mixer)?;
|
|
||||||
|
|
||||||
//looper::render(&mut state.looper, stdout, (offset.0 + 1, 28))?;
|
|
||||||
//render::render_box(stdout, Some("Looper"), offset.0, 27, 70, 6,
|
|
||||||
//state.mode == Mode::Looper)?;
|
|
||||||
|
|
||||||
//Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,54 +130,20 @@ impl HandleInput for App {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
KeyCode::Tab => {
|
KeyCode::Tab => {
|
||||||
match self.mode {
|
self.focus = self.focus + 1;
|
||||||
Mode::Transport => self.mode = Mode::Sequencer,
|
if self.focus >= self.devices.len() {
|
||||||
Mode::Sequencer => self.mode = Mode::Sampler,
|
self.focus = 0;
|
||||||
Mode::Sampler => self.mode = Mode::Mixer,
|
|
||||||
Mode::Mixer => self.mode = Mode::Looper,
|
|
||||||
Mode::Looper => self.mode = Mode::Transport,
|
|
||||||
_ => {}
|
|
||||||
};
|
|
||||||
self.actions.clear();
|
|
||||||
self.actions.extend_from_slice(&transport::ACTIONS);
|
|
||||||
match self.mode {
|
|
||||||
Mode::Transport => {},
|
|
||||||
Mode::Mixer => self.actions.extend_from_slice(&mixer::ACTIONS),
|
|
||||||
Mode::Looper => self.actions.extend_from_slice(&looper::ACTIONS),
|
|
||||||
Mode::Sampler => self.actions.extend_from_slice(&sampler::ACTIONS),
|
|
||||||
Mode::Sequencer => self.actions.extend_from_slice(&sequencer::ACTIONS),
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
KeyCode::BackTab => {
|
KeyCode::BackTab => {
|
||||||
match self.mode {
|
if self.focus == 0 {
|
||||||
Mode::Transport => self.mode = Mode::Looper,
|
self.focus = self.devices.len() - 1;
|
||||||
Mode::Sequencer => self.mode = Mode::Transport,
|
} else {
|
||||||
Mode::Sampler => self.mode = Mode::Sequencer,
|
self.focus = self.focus - 1;
|
||||||
Mode::Mixer => self.mode = Mode::Sampler,
|
|
||||||
Mode::Looper => self.mode = Mode::Mixer,
|
|
||||||
_ => {}
|
|
||||||
};
|
|
||||||
self.actions.clear();
|
|
||||||
self.actions.extend_from_slice(&transport::ACTIONS);
|
|
||||||
match self.mode {
|
|
||||||
Mode::Transport => {},
|
|
||||||
Mode::Mixer => self.actions.extend_from_slice(&mixer::ACTIONS),
|
|
||||||
Mode::Looper => self.actions.extend_from_slice(&looper::ACTIONS),
|
|
||||||
Mode::Sampler => self.actions.extend_from_slice(&sampler::ACTIONS),
|
|
||||||
Mode::Sequencer => self.actions.extend_from_slice(&sequencer::ACTIONS),
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => match self.mode {
|
_ => {
|
||||||
Mode::Transport => self.transport
|
self.devices[self.focus].handle(&event)?
|
||||||
.handle(&event)?,
|
|
||||||
Mode::Mixer => self.mixer
|
|
||||||
.handle(&event)?,
|
|
||||||
Mode::Looper => self.looper
|
|
||||||
.handle(&event)?,
|
|
||||||
Mode::Sampler => self.sampler
|
|
||||||
.handle(&event)?,
|
|
||||||
Mode::Sequencer => self.sequencers[0]
|
|
||||||
.handle(&event)?,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,57 +29,27 @@ impl<'a> WidgetRef for ActionBar<'a> {
|
||||||
|
|
||||||
pub fn draw_leaf (buffer: &mut Buffer, area: Rect, y: u16, x: u16, text: &str) {
|
pub fn draw_leaf (buffer: &mut Buffer, area: Rect, y: u16, x: u16, text: &str) {
|
||||||
use ratatui::style::{Style, Stylize};
|
use ratatui::style::{Style, Stylize};
|
||||||
buffer.set_string(
|
let border = Style::default().gray().dim();
|
||||||
area.x + x, area.y + y,
|
let label = Style::default();
|
||||||
format!("│"),
|
let side = String::from("│");
|
||||||
Style::default().black().dim()
|
let bottom = format!("╰{}╯", "─".repeat(text.len() as usize));
|
||||||
);
|
buffer.set_string(area.x + x, area.y + y, &side, border);
|
||||||
buffer.set_string(
|
buffer.set_string(area.x + x + 1, area.y + y, format!("{text}"), label);
|
||||||
area.x + x + 1, area.y + y,
|
buffer.set_string(area.x + x + text.len() as u16 + 1, area.y + y, &side, border);
|
||||||
format!("{text}"),
|
buffer.set_string(area.x + x, area.y + 1 + y, bottom, border);
|
||||||
Style::default()
|
|
||||||
);
|
|
||||||
buffer.set_string(
|
|
||||||
area.x + x + text.len() as u16 + 1, area.y + y,
|
|
||||||
format!("│"),
|
|
||||||
Style::default().black().dim()
|
|
||||||
);
|
|
||||||
buffer.set_string(
|
|
||||||
area.x + x, area.y + 1 + y,
|
|
||||||
format!("╰{}╯", "─".repeat(text.len() as usize)),
|
|
||||||
Style::default().black()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_box (buffer: &mut Buffer, area: Rect) {
|
pub fn draw_box (buffer: &mut Buffer, area: Rect) {
|
||||||
use ratatui::style::{Style, Stylize};
|
use ratatui::style::{Style, Stylize};
|
||||||
buffer.set_string(
|
let border = Style::default().gray().dim();
|
||||||
area.x, area.y,
|
let top = format!("╭{}╮", "─".repeat((area.width - 2).into()));
|
||||||
format!("╭{}╮", "─".repeat((area.width - 2).into())),//.repeat(area.width.saturating_sub(2).into())),
|
let bottom = format!("╰{}╯", "─".repeat((area.width - 2).into()));
|
||||||
Style::default().black()
|
buffer.set_string(area.x, area.y, top, border);
|
||||||
);
|
|
||||||
for y in (area.y + 1)..(area.y + area.height - 1) {
|
for y in (area.y + 1)..(area.y + area.height - 1) {
|
||||||
buffer.set_string(
|
buffer.set_string(area.x, y, format!("│"), border);
|
||||||
area.x, y,
|
buffer.set_string(area.x + area.width - 1, y, format!("│"), border);
|
||||||
format!("│"),
|
|
||||||
Style::default().black().dim()
|
|
||||||
);
|
|
||||||
buffer.set_string(
|
|
||||||
area.x + area.width - 1, y,
|
|
||||||
format!("│"),
|
|
||||||
Style::default().black().dim()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
buffer.set_string(
|
buffer.set_string(area.x, area.y + area.height - 1, bottom, border);
|
||||||
area.x, area.y + area.height - 1,
|
|
||||||
format!("╰{}╯", "─".repeat((area.width - 2).into())),//.repeat(area.width.saturating_sub(2).into())),
|
|
||||||
Style::default().black()
|
|
||||||
);
|
|
||||||
//buffer.set_string(
|
|
||||||
//area.x, area.y + area.height,
|
|
||||||
//format!("╰{}╯", "─".repeat(area.width.saturating_sub(2).into())),
|
|
||||||
//Style::default().black()
|
|
||||||
//);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_toolbar_vertical (
|
pub fn render_toolbar_vertical (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue