mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: fix one batch of errors, unlock another
This commit is contained in:
parent
a54798994b
commit
10f191282e
14 changed files with 92 additions and 28 deletions
|
|
@ -12,6 +12,7 @@ submod! {
|
|||
midi
|
||||
phrase
|
||||
sequencer
|
||||
sequencer_cli
|
||||
sequencer_control
|
||||
sequencer_track
|
||||
arranger
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! Phrase editor.
|
||||
include!("lib.rs");
|
||||
pub fn main () -> Usually<()> {
|
||||
tek_core::run(Arc::new(RwLock::new(crate::Sequencer::new())))?;
|
||||
tek_core::run(Arc::new(RwLock::new(crate::Sequencer::from_args())))?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::*;
|
||||
use tek_jack::jack::*;
|
||||
|
||||
/// MIDI message serialized to bytes
|
||||
pub type MIDIMessage = Vec<u8>;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,5 @@
|
|||
use crate::*;
|
||||
|
||||
/// Define a MIDI phrase.
|
||||
#[macro_export] macro_rules! phrase {
|
||||
($($t:expr => $msg:expr),* $(,)?) => {{
|
||||
#[allow(unused_mut)]
|
||||
let mut phrase = BTreeMap::new();
|
||||
$(phrase.insert($t, vec![]);)*
|
||||
$(phrase.get_mut(&$t).unwrap().push($msg);)*
|
||||
phrase
|
||||
}}
|
||||
}
|
||||
|
||||
pub type PhraseData = Vec<Vec<MidiMessage>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
/// A MIDI sequence.
|
||||
pub struct Phrase {
|
||||
|
|
@ -24,6 +11,8 @@ pub struct Phrase {
|
|||
pub percussive: bool
|
||||
}
|
||||
|
||||
pub type PhraseData = Vec<Vec<MidiMessage>>;
|
||||
|
||||
impl Default for Phrase {
|
||||
fn default () -> Self {
|
||||
Self::new("", 0, None)
|
||||
|
|
@ -91,3 +80,14 @@ impl Phrase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Define a MIDI phrase.
|
||||
#[macro_export] macro_rules! phrase {
|
||||
($($t:expr => $msg:expr),* $(,)?) => {{
|
||||
#[allow(unused_mut)]
|
||||
let mut phrase = BTreeMap::new();
|
||||
$(phrase.insert($t, vec![]);)*
|
||||
$(phrase.get_mut(&$t).unwrap().push($msg);)*
|
||||
phrase
|
||||
}}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ use crate::*;
|
|||
|
||||
/// Phrase editor.
|
||||
pub struct Sequencer {
|
||||
pub name: String,
|
||||
pub mode: bool,
|
||||
pub focused: bool,
|
||||
pub entered: bool,
|
||||
|
||||
pub phrase: Option<Arc<RwLock<Phrase>>>,
|
||||
pub transport: Option<Arc<RwLock<TransportToolbar>>>,
|
||||
pub buffer: BigBuffer,
|
||||
pub keys: Buffer,
|
||||
/// Highlight input keys
|
||||
|
|
@ -34,6 +36,7 @@ handle!(Sequencer |self, e| handle_keymap(self, e, KEYMAP_SEQUENCER));
|
|||
impl Sequencer {
|
||||
pub fn new () -> Self {
|
||||
Self {
|
||||
name: "".into(),
|
||||
buffer: Default::default(),
|
||||
keys: keys_vert(),
|
||||
entered: false,
|
||||
|
|
@ -44,6 +47,7 @@ impl Sequencer {
|
|||
phrase: None,
|
||||
now: 0,
|
||||
ppq: 96,
|
||||
transport: None,
|
||||
note_axis: FixedAxis {
|
||||
start: 12,
|
||||
point: Some(36)
|
||||
|
|
|
|||
40
crates/tek_sequencer/src/sequencer_cli.rs
Normal file
40
crates/tek_sequencer/src/sequencer_cli.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//! Command line option parser.
|
||||
|
||||
use tek_core::clap::{self, Parser, Subcommand};
|
||||
use tek_timer::TransportToolbar;
|
||||
use crate::*;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct SequencerCli {
|
||||
/// Name of JACK client
|
||||
#[arg(short, long)] name: Option<String>,
|
||||
/// Pulses per quarter note (sequencer resolution; default: 96)
|
||||
#[arg(short, long)] ppq: Option<usize>,
|
||||
/// Default phrase duration (in pulses; default: 4 * PPQ = 1 bar)
|
||||
#[arg(short, long)] length: Option<usize>,
|
||||
/// Whether to include a transport toolbar (default: true)
|
||||
#[arg(short, long)] transport: Option<bool>
|
||||
}
|
||||
|
||||
impl Sequencer {
|
||||
pub fn from_args () -> Self {
|
||||
let args = SequencerCli::parse();
|
||||
let mut seq = Self::new();
|
||||
if let Some(name) = args.name {
|
||||
seq.name = name.clone();
|
||||
}
|
||||
if let Some(ppq) = args.ppq {
|
||||
seq.ppq = ppq;
|
||||
}
|
||||
if let Some(length) = args.length {
|
||||
if let Some(phrase) = seq.phrase.as_mut() {
|
||||
phrase.write().unwrap().length = length;
|
||||
}
|
||||
}
|
||||
if args.transport == Some(true) {
|
||||
seq.transport = Some(Arc::new(RwLock::new(TransportToolbar::new(None))));
|
||||
}
|
||||
seq
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue