mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
basic midi import example
This commit is contained in:
parent
35944cf684
commit
f5b1f495ad
8 changed files with 114 additions and 66 deletions
|
|
@ -57,10 +57,10 @@ macro_rules! impl_midi_player {
|
|||
fn reset_mut (&mut self) -> &mut bool {
|
||||
&mut self$(.$field)*.reset
|
||||
}
|
||||
fn phrase (&self) -> &Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
fn play_phrase (&self) -> &Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
&self$(.$field)*.play_phrase
|
||||
}
|
||||
fn phrase_mut (&mut self) -> &mut Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
fn play_phrase_mut (&mut self) -> &mut Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
&mut self$(.$field)*.play_phrase
|
||||
}
|
||||
fn next_phrase (&self) -> &Option<(Instant, Option<Arc<RwLock<Phrase>>>)> {
|
||||
|
|
|
|||
|
|
@ -97,18 +97,20 @@ fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<Seque
|
|||
AppFocus::Menu => {
|
||||
todo!()
|
||||
},
|
||||
AppFocus::Content(SequencerFocus::Transport(_)) => {
|
||||
match TransportCommand::input_to_command(state, input)? {
|
||||
TransportCommand::Clock(_) => { todo!() },
|
||||
TransportCommand::Focus(command) => Cmd::Focus(command),
|
||||
}
|
||||
},
|
||||
AppFocus::Content(SequencerFocus::Phrases) => {
|
||||
Cmd::Phrases(PhrasesCommand::input_to_command(state, input)?)
|
||||
},
|
||||
AppFocus::Content(SequencerFocus::PhraseEditor) => {
|
||||
Cmd::Editor(PhraseCommand::input_to_command(state, input)?)
|
||||
},
|
||||
AppFocus::Content(focused) => match focused {
|
||||
SequencerFocus::Transport(_) => {
|
||||
match TransportCommand::input_to_command(state, input)? {
|
||||
TransportCommand::Clock(_) => { todo!() },
|
||||
TransportCommand::Focus(command) => Cmd::Focus(command),
|
||||
}
|
||||
},
|
||||
SequencerFocus::Phrases => {
|
||||
Cmd::Phrases(PhrasesCommand::input_to_command(state, input)?)
|
||||
},
|
||||
SequencerFocus::PhraseEditor => {
|
||||
Cmd::Editor(PhraseCommand::input_to_command(state, input)?)
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -118,43 +120,47 @@ fn to_arranger_command (state: &ArrangerTui, input: &TuiInput) -> Option<Arrange
|
|||
return None
|
||||
}
|
||||
Some(match state.focused() {
|
||||
AppFocus::Menu => todo!(),
|
||||
AppFocus::Content(ArrangerFocus::Transport(_)) => {
|
||||
use TransportCommand::{Clock, Focus};
|
||||
match TransportCommand::input_to_command(state, input)? {
|
||||
Clock(_) => { todo!() },
|
||||
Focus(command) => Cmd::Focus(command)
|
||||
}
|
||||
AppFocus::Menu => {
|
||||
todo!()
|
||||
},
|
||||
AppFocus::Content(ArrangerFocus::PhraseEditor) => {
|
||||
Cmd::Editor(PhraseCommand::input_to_command(state, input)?)
|
||||
},
|
||||
AppFocus::Content(ArrangerFocus::Phrases) => match input.event() {
|
||||
key!(KeyCode::Char('e')) => {
|
||||
Cmd::EditPhrase(state.phrase_editing().clone())
|
||||
AppFocus::Content(focused) => match focused {
|
||||
ArrangerFocus::Transport(_) => {
|
||||
use TransportCommand::{Clock, Focus};
|
||||
match TransportCommand::input_to_command(state, input)? {
|
||||
Clock(_) => { todo!() },
|
||||
Focus(command) => Cmd::Focus(command)
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
Cmd::Phrases(PhrasesCommand::input_to_command(state, input)?)
|
||||
}
|
||||
},
|
||||
AppFocus::Content(ArrangerFocus::Arranger) => {
|
||||
use ArrangerSelection::*;
|
||||
use KeyCode::Char;
|
||||
match input.event() {
|
||||
key!(Char('e')) => Cmd::EditPhrase(state.phrase_editing().clone()),
|
||||
key!(Char('l')) => Cmd::Clip(ArrangerClipCommand::SetLoop(false)),
|
||||
key!(Char('+')) => Cmd::Zoom(0), // TODO
|
||||
key!(Char('=')) => Cmd::Zoom(0), // TODO
|
||||
key!(Char('_')) => Cmd::Zoom(0), // TODO
|
||||
key!(Char('-')) => Cmd::Zoom(0), // TODO
|
||||
key!(Char('`')) => { todo!("toggle state mode") },
|
||||
key!(Ctrl-Char('a')) => Cmd::Scene(ArrangerSceneCommand::Add),
|
||||
key!(Ctrl-Char('t')) => Cmd::Track(ArrangerTrackCommand::Add),
|
||||
_ => match state.selected() {
|
||||
Mix => to_arranger_mix_command(input)?,
|
||||
Track(t) => to_arranger_track_command(input, t)?,
|
||||
Scene(s) => to_arranger_scene_command(input, s)?,
|
||||
Clip(t, s) => to_arranger_clip_command(input, t, s)?,
|
||||
ArrangerFocus::PhraseEditor => {
|
||||
Cmd::Editor(PhraseCommand::input_to_command(state, input)?)
|
||||
},
|
||||
ArrangerFocus::Phrases => match input.event() {
|
||||
key!(KeyCode::Char('e')) => {
|
||||
Cmd::EditPhrase(state.phrase_editing().clone())
|
||||
},
|
||||
_ => {
|
||||
Cmd::Phrases(PhrasesCommand::input_to_command(state, input)?)
|
||||
}
|
||||
},
|
||||
ArrangerFocus::Arranger => {
|
||||
use ArrangerSelection::*;
|
||||
use KeyCode::Char;
|
||||
match input.event() {
|
||||
key!(Char('e')) => Cmd::EditPhrase(state.phrase_editing().clone()),
|
||||
key!(Char('l')) => Cmd::Clip(ArrangerClipCommand::SetLoop(false)),
|
||||
key!(Char('+')) => Cmd::Zoom(0), // TODO
|
||||
key!(Char('=')) => Cmd::Zoom(0), // TODO
|
||||
key!(Char('_')) => Cmd::Zoom(0), // TODO
|
||||
key!(Char('-')) => Cmd::Zoom(0), // TODO
|
||||
key!(Char('`')) => { todo!("toggle state mode") },
|
||||
key!(Ctrl-Char('a')) => Cmd::Scene(ArrangerSceneCommand::Add),
|
||||
key!(Ctrl-Char('t')) => Cmd::Track(ArrangerTrackCommand::Add),
|
||||
_ => match state.selected() {
|
||||
Mix => to_arranger_mix_command(input)?,
|
||||
Track(t) => to_arranger_track_command(input, t)?,
|
||||
Scene(s) => to_arranger_scene_command(input, s)?,
|
||||
Clip(t, s) => to_arranger_clip_command(input, t, s)?,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -288,7 +294,10 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhrasesCommand {
|
|||
index + 1,
|
||||
state.phrases()[index].read().unwrap().duplicate()
|
||||
)),
|
||||
key!(Char('c')) => Self::Phrase(Pool::Color(index, ItemColor::random())),
|
||||
key!(Char('c')) => Self::Phrase(Pool::SetColor(
|
||||
index,
|
||||
ItemColor::random()
|
||||
)),
|
||||
key!(Char('n')) => Self::Rename(Rename::Begin),
|
||||
key!(Char('t')) => Self::Length(Length::Begin),
|
||||
_ => match state.phrases_mode() {
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ pub fn arranger_content_vertical (
|
|||
let name = format!("▎{}", &name[0..max_w]);
|
||||
let name = TuiStyle::bold(name, true);
|
||||
// beats elapsed
|
||||
let elapsed = if let Some((_, Some(phrase))) = track.phrase().as_ref() {
|
||||
let elapsed = if let Some((_, Some(phrase))) = track.play_phrase().as_ref() {
|
||||
let length = phrase.read().unwrap().length;
|
||||
let elapsed = track.pulses_since_start().unwrap();
|
||||
let elapsed = timebase.format_beats_1_short(
|
||||
|
|
@ -282,7 +282,7 @@ pub fn arranger_content_vertical (
|
|||
let color = phrase.read().unwrap().color;
|
||||
add(&name.as_str()[0..max_w].push_x(1).fixed_x(w as u16))?;
|
||||
bg = color.dark.rgb;
|
||||
if let Some((_, Some(ref playing))) = track.phrase() {
|
||||
if let Some((_, Some(ref playing))) = track.play_phrase() {
|
||||
if *playing.read().unwrap() == *phrase.read().unwrap() {
|
||||
bg = color.light.rgb
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue