tab toggles pool visibility in sequencer

This commit is contained in:
🪞👃🪞 2024-12-15 16:39:49 +01:00
parent 33259d1526
commit f71ee5c521
2 changed files with 34 additions and 26 deletions

View file

@ -20,12 +20,12 @@ pub struct SequencerCli {
impl SequencerCli {
fn run (&self) -> Usually<()> {
Tui::run(JackClient::new("tek_sequencer")?.activate_with(|jack|{
let midi_in = jack.read().unwrap().register_port("in", MidiIn::default())?;
let midi_out = jack.read().unwrap().register_port("out", MidiOut::default())?;
let mut app = SequencerTui::try_from(jack)?;
//app.editor.view_mode.set_time_zoom(1);
// TODO: create from arguments
let midi_in = app.jack.read().unwrap().register_port("in", MidiIn::default())?;
app.player.midi_ins.push(midi_in);
let midi_out = app.jack.read().unwrap().register_port("out", MidiOut::default())?;
app.player.midi_outs.push(midi_out);
if let Some(_) = self.name.as_ref() {
// TODO: sequencer.name = Arc::new(RwLock::new(name.clone()));

View file

@ -16,17 +16,16 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for SequencerTui {
Some(ItemColor::random().into())
)));
Ok(Self {
jack: jack.clone(),
_jack: jack.clone(),
phrases: PhraseListModel::from(&phrase),
editor: PhraseEditorModel::from(&phrase),
player: PhrasePlayerModel::from((&clock, &phrase)),
clock,
size: Measure::new(),
cursor: (0, 0),
split: 20,
midi_buf: vec![vec![];65536],
note_buf: vec![],
perf: PerfModel::default(),
show_pool: true,
})
}
@ -34,17 +33,16 @@ impl TryFrom<&Arc<RwLock<JackClient>>> for SequencerTui {
/// Root view for standalone `tek_sequencer`.
pub struct SequencerTui {
pub jack: Arc<RwLock<JackClient>>,
pub clock: ClockModel,
pub phrases: PhraseListModel,
pub player: PhrasePlayerModel,
pub editor: PhraseEditorModel,
pub size: Measure<Tui>,
pub cursor: (usize, usize),
pub split: u16,
pub note_buf: Vec<u8>,
pub midi_buf: Vec<Vec<Vec<u8>>>,
pub perf: PerfModel,
_jack: Arc<RwLock<JackClient>>,
pub(crate) clock: ClockModel,
pub(crate) phrases: PhraseListModel,
pub(crate) player: PhrasePlayerModel,
pub(crate) editor: PhraseEditorModel,
pub(crate) size: Measure<Tui>,
pub(crate) show_pool: bool,
pub(crate) note_buf: Vec<u8>,
pub(crate) midi_buf: Vec<Vec<Vec<u8>>>,
pub(crate) perf: PerfModel,
}
#[derive(Clone, Debug)]
@ -53,6 +51,7 @@ pub enum SequencerCommand {
Phrases(PhrasesCommand),
Editor(PhraseCommand),
Enqueue(Option<Arc<RwLock<Phrase>>>),
ShowPool(bool),
}
impl Command<SequencerTui> for SequencerCommand {
@ -75,6 +74,10 @@ impl Command<SequencerTui> for SequencerCommand {
state.player.enqueue_next(phrase.as_ref());
None
},
Self::ShowPool(value) => {
state.show_pool = value;
None
}
})
}
}
@ -88,6 +91,9 @@ impl InputToCommand<Tui, SequencerTui> for SequencerCommand {
pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<SequencerCommand> {
Some(match input.event() {
// Toggle visibility of phrase pool column
key_pat!(Tab) => ShowPool(!state.show_pool),
// Enqueue currently edited phrase
key_pat!(Char('q')) => Enqueue(Some(
state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone()
@ -137,7 +143,7 @@ pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<S
})
}
audio!(|self:SequencerTui,client,scope|{
audio!(|self:SequencerTui, client, scope|{
// Start profiling cycle
let t0 = self.perf.get_t0();
// Update transport clock
@ -160,7 +166,9 @@ render!(|self: SequencerTui|lay!([self.size, Tui::split_n(false, 5,
PhraseEditStatus(&self.editor),
SequencerStatusBar::from(self),
])),
Tui::split_w(false, if self.size.w() > 60 {
Tui::split_w(false, if !self.show_pool{
0
} else if self.size.w() > 60 {
20
} else if self.size.w() > 40 {
15