mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +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
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