mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
put all of arranger/sequencer/transport in 1 file
This commit is contained in:
parent
3042e9e3a8
commit
6f988e5072
12 changed files with 1877 additions and 1847 deletions
42
crates/tek_sequencer/src/main_sequencer.rs
Normal file
42
crates/tek_sequencer/src/main_sequencer.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//! Phrase editor.
|
||||
include!("lib.rs");
|
||||
pub fn main () -> Usually<()> {
|
||||
Tui::run(Arc::new(RwLock::new(crate::Sequencer::from_args()))).map(|_|())
|
||||
}
|
||||
|
||||
use tek_core::clap::{self, Parser};
|
||||
|
||||
#[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<Tui> {
|
||||
pub fn from_args () -> Self {
|
||||
let args = SequencerCli::parse();
|
||||
let mut seq = Self::new("");
|
||||
if let Some(name) = args.name {
|
||||
seq.name = Arc::new(RwLock::new(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