mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
feat: run stub tek_sequencer
This commit is contained in:
parent
b8a67b8adc
commit
09abc4cd95
12 changed files with 78 additions and 56 deletions
|
|
@ -1,8 +1,4 @@
|
||||||
pub(crate) use tek_core::*;
|
include!("lib.rs");
|
||||||
pub(crate) use tek_core::ratatui::prelude::*;
|
|
||||||
pub(crate) use tek_jack::*;
|
|
||||||
pub(crate) use std::sync::RwLockWriteGuard;
|
|
||||||
submod! { chain chain_view }
|
|
||||||
pub fn main () -> Usually<()> {
|
pub fn main () -> Usually<()> {
|
||||||
tek_core::run(Arc::new(RwLock::new(crate::Chain::new("todo")?)))?;
|
tek_core::run(Arc::new(RwLock::new(crate::Chain::new("todo")?)))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,10 @@ tek_core = { path = "../tek_core" }
|
||||||
tek_jack = { path = "../tek_jack" }
|
tek_jack = { path = "../tek_jack" }
|
||||||
symphonia = { version = "0.5.4", features = [ "all" ] }
|
symphonia = { version = "0.5.4", features = [ "all" ] }
|
||||||
wavers = "1.4.3"
|
wavers = "1.4.3"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "tek_sampler"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
//! Sampler (currently 16bit WAVs at system rate; TODO convert/resample)
|
// Sampler (currently 16bit WAVs at system rate; TODO convert/resample)
|
||||||
|
|
||||||
pub(crate) use tek_core::*;
|
pub(crate) use tek_core::*;
|
||||||
pub(crate) use tek_core::ratatui::prelude::*;
|
pub(crate) use tek_core::ratatui::prelude::*;
|
||||||
|
|
|
||||||
6
crates/tek_sampler/src/main.rs
Normal file
6
crates/tek_sampler/src/main.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
//! Phrase editor.
|
||||||
|
include!("lib.rs");
|
||||||
|
pub fn main () -> Usually<()> {
|
||||||
|
tek_core::run(Arc::new(RwLock::new(crate::Sampler::new("sampler", None)?)));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,8 @@ pub struct Sampler {
|
||||||
pub output_gain: f32
|
pub output_gain: f32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process!(Sampler = Sampler::process);
|
||||||
|
handle!(Sampler |self, event| handle_keymap(self, event, KEYMAP_SAMPLER));
|
||||||
render!(Sampler |self, buf, area| {
|
render!(Sampler |self, buf, area| {
|
||||||
let Rect { x, y, height, .. } = area;
|
let Rect { x, y, height, .. } = area;
|
||||||
let style = Style::default().gray();
|
let style = Style::default().gray();
|
||||||
|
|
@ -56,8 +58,6 @@ fn draw_sample (
|
||||||
Ok(label1.len() + label2.len() + 4)
|
Ok(label1.len() + label2.len() + 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
handle!(Sampler |self, event| handle_keymap(self, event, KEYMAP_SAMPLER));
|
|
||||||
|
|
||||||
/// Key bindings for sampler device.
|
/// Key bindings for sampler device.
|
||||||
pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
||||||
[Up, NONE, "/sampler/cursor/up", "move cursor up", |state: &mut Sampler| {
|
[Up, NONE, "/sampler/cursor/up", "move cursor up", |state: &mut Sampler| {
|
||||||
|
|
@ -98,7 +98,6 @@ pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
process!(Sampler = Sampler::process);
|
|
||||||
|
|
||||||
impl Sampler {
|
impl Sampler {
|
||||||
pub fn new (name: &str, mapped: Option<BTreeMap<u7, Arc<RwLock<Sample>>>>) -> Usually<JackDevice> {
|
pub fn new (name: &str, mapped: Option<BTreeMap<u7, Arc<RwLock<Sample>>>>) -> Usually<JackDevice> {
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,10 @@ version = "0.1.0"
|
||||||
tek_core = { path = "../tek_core" }
|
tek_core = { path = "../tek_core" }
|
||||||
tek_jack = { path = "../tek_jack" }
|
tek_jack = { path = "../tek_jack" }
|
||||||
tek_timer = { path = "../tek_timer" }
|
tek_timer = { path = "../tek_timer" }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "tek_sequencer"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fn main () {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
//! Phrase editor.
|
/// Phrase editor.
|
||||||
|
|
||||||
pub(crate) use tek_core::*;
|
pub(crate) use tek_core::*;
|
||||||
pub(crate) use tek_core::ratatui::prelude::*;
|
pub(crate) use tek_core::ratatui::prelude::*;
|
||||||
pub(crate) use tek_core::crossterm::event::{KeyCode, KeyModifiers};
|
pub(crate) use tek_core::crossterm::event::{KeyCode, KeyModifiers};
|
||||||
pub(crate) use tek_core::midly::{num::u7, live::LiveEvent, MidiMessage};
|
pub(crate) use tek_core::midly::{num::u7, live::LiveEvent, MidiMessage};
|
||||||
pub(crate) use tek_jack::{*, jack::*};
|
pub(crate) use tek_jack::jack::*;
|
||||||
pub(crate) use tek_timer::*;
|
pub(crate) use tek_timer::*;
|
||||||
pub(crate) use std::sync::{Arc, RwLock};
|
pub(crate) use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
|
|
@ -12,6 +12,7 @@ submod! {
|
||||||
midi
|
midi
|
||||||
phrase
|
phrase
|
||||||
sequencer
|
sequencer
|
||||||
|
sequencer_control
|
||||||
sequencer_track
|
sequencer_track
|
||||||
arranger
|
arranger
|
||||||
arranger_focus
|
arranger_focus
|
||||||
|
|
@ -24,45 +25,3 @@ pubmod! {
|
||||||
arranger_view_h
|
arranger_view_h
|
||||||
arranger_view_v
|
arranger_view_v
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Key bindings for phrase editor.
|
|
||||||
pub const KEYMAP_SEQUENCER: &'static [KeyBinding<Sequencer>] = keymap!(Sequencer {
|
|
||||||
[Up, NONE, "seq_cursor_up", "move cursor up", |sequencer: &mut Sequencer| {
|
|
||||||
match sequencer.entered {
|
|
||||||
true => { sequencer.note_axis.point_dec(); },
|
|
||||||
false => { sequencer.note_axis.start_dec(); },
|
|
||||||
}
|
|
||||||
Ok(true)
|
|
||||||
}],
|
|
||||||
[Down, NONE, "seq_cursor_down", "move cursor down", |sequencer: &mut Sequencer| {
|
|
||||||
match sequencer.entered {
|
|
||||||
true => { sequencer.note_axis.point_inc(); },
|
|
||||||
false => { sequencer.note_axis.start_inc(); },
|
|
||||||
}
|
|
||||||
Ok(true)
|
|
||||||
}],
|
|
||||||
[Left, NONE, "seq_cursor_left", "move cursor up", |sequencer: &mut Sequencer| {
|
|
||||||
match sequencer.entered {
|
|
||||||
true => { sequencer.time_axis.point_dec(); },
|
|
||||||
false => { sequencer.time_axis.start_dec(); },
|
|
||||||
}
|
|
||||||
Ok(true)
|
|
||||||
}],
|
|
||||||
[Right, NONE, "seq_cursor_right", "move cursor up", |sequencer: &mut Sequencer| {
|
|
||||||
match sequencer.entered {
|
|
||||||
true => { sequencer.time_axis.point_inc(); },
|
|
||||||
false => { sequencer.time_axis.start_inc(); },
|
|
||||||
}
|
|
||||||
Ok(true)
|
|
||||||
}],
|
|
||||||
[Char('`'), NONE, "seq_mode_switch", "switch the display mode", |sequencer: &mut Sequencer| {
|
|
||||||
sequencer.mode = !sequencer.mode;
|
|
||||||
Ok(true)
|
|
||||||
}],
|
|
||||||
/*
|
|
||||||
[Char('a'), NONE, "note_add", "Add note", note_add],
|
|
||||||
[Char('z'), NONE, "note_del", "Delete note", note_del],
|
|
||||||
[CapsLock, NONE, "advance", "Toggle auto advance", nop],
|
|
||||||
[Char('w'), NONE, "rest", "Advance by note duration", nop],
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
|
|
|
||||||
6
crates/tek_sequencer/src/main.rs
Normal file
6
crates/tek_sequencer/src/main.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
//! Phrase editor.
|
||||||
|
include!("lib.rs");
|
||||||
|
pub fn main () -> Usually<()> {
|
||||||
|
tek_core::run(Arc::new(RwLock::new(crate::Sequencer::new())))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -29,6 +29,8 @@ render!(Sequencer |self, buf, area| {
|
||||||
Ok(area)
|
Ok(area)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
handle!(Sequencer |self, e| handle_keymap(self, e, KEYMAP_SEQUENCER));
|
||||||
|
|
||||||
impl Sequencer {
|
impl Sequencer {
|
||||||
pub fn new () -> Self {
|
pub fn new () -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
||||||
43
crates/tek_sequencer/src/sequencer_control.rs
Normal file
43
crates/tek_sequencer/src/sequencer_control.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
/// Key bindings for phrase editor.
|
||||||
|
pub const KEYMAP_SEQUENCER: &'static [KeyBinding<Sequencer>] = keymap!(Sequencer {
|
||||||
|
[Up, NONE, "seq_cursor_up", "move cursor up", |sequencer: &mut Sequencer| {
|
||||||
|
match sequencer.entered {
|
||||||
|
true => { sequencer.note_axis.point_dec(); },
|
||||||
|
false => { sequencer.note_axis.start_dec(); },
|
||||||
|
}
|
||||||
|
Ok(true)
|
||||||
|
}],
|
||||||
|
[Down, NONE, "seq_cursor_down", "move cursor down", |sequencer: &mut Sequencer| {
|
||||||
|
match sequencer.entered {
|
||||||
|
true => { sequencer.note_axis.point_inc(); },
|
||||||
|
false => { sequencer.note_axis.start_inc(); },
|
||||||
|
}
|
||||||
|
Ok(true)
|
||||||
|
}],
|
||||||
|
[Left, NONE, "seq_cursor_left", "move cursor up", |sequencer: &mut Sequencer| {
|
||||||
|
match sequencer.entered {
|
||||||
|
true => { sequencer.time_axis.point_dec(); },
|
||||||
|
false => { sequencer.time_axis.start_dec(); },
|
||||||
|
}
|
||||||
|
Ok(true)
|
||||||
|
}],
|
||||||
|
[Right, NONE, "seq_cursor_right", "move cursor up", |sequencer: &mut Sequencer| {
|
||||||
|
match sequencer.entered {
|
||||||
|
true => { sequencer.time_axis.point_inc(); },
|
||||||
|
false => { sequencer.time_axis.start_inc(); },
|
||||||
|
}
|
||||||
|
Ok(true)
|
||||||
|
}],
|
||||||
|
[Char('`'), NONE, "seq_mode_switch", "switch the display mode", |sequencer: &mut Sequencer| {
|
||||||
|
sequencer.mode = !sequencer.mode;
|
||||||
|
Ok(true)
|
||||||
|
}],
|
||||||
|
/*
|
||||||
|
[Char('a'), NONE, "note_add", "Add note", note_add],
|
||||||
|
[Char('z'), NONE, "note_del", "Delete note", note_del],
|
||||||
|
[CapsLock, NONE, "advance", "Toggle auto advance", nop],
|
||||||
|
[Char('w'), NONE, "rest", "Advance by note duration", nop],
|
||||||
|
*/
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue