mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
stub sampler import command
This commit is contained in:
parent
17efdb9b8e
commit
9bd898ab33
6 changed files with 22 additions and 18 deletions
|
|
@ -14,7 +14,7 @@ use crate::*;
|
|||
($Command:ty: <$Engine:ty>|$state:ident:$State:ty,$input:ident|$handler:expr) => {
|
||||
impl InputToCommand<$Engine, $State> for $Command {
|
||||
fn input_to_command ($state: &$State, $input: &<$Engine as Engine>::Input) -> Option<Self> {
|
||||
$handler
|
||||
Some($handler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::*;
|
||||
use super::*;
|
||||
use KeyCode::Char;
|
||||
|
||||
impl TryFrom<&Arc<RwLock<JackClient>>> for GrooveboxTui {
|
||||
type Error = Box<dyn std::error::Error>;
|
||||
|
|
@ -28,5 +29,9 @@ pub enum GrooveboxCommand {
|
|||
render!(|self:GrooveboxTui|Bsp::s(Tui::fixed_y(self.split, &self.sequencer), &self.sampler));
|
||||
audio!(|self:GrooveboxTui,_client,_process|Control::Continue);
|
||||
handle!(<Tui>|self:GrooveboxTui,input|GrooveboxCommand::execute_with_state(self, input));
|
||||
input_to_command!(GrooveboxCommand: <Tui>|state:GrooveboxTui,input|match input.event() {
|
||||
// load sample
|
||||
key_pat!(Char('l')) => GrooveboxCommand::Sampler(SamplerCommand::Import),
|
||||
_ => GrooveboxCommand::Sequencer(SequencerCommand::input_to_command(&state.sequencer, input)?),
|
||||
});
|
||||
command!(|self:GrooveboxCommand,state:GrooveboxTui|todo!());
|
||||
input_to_command!(GrooveboxCommand: <Tui>|state:GrooveboxTui,input|todo!());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use symphonia::core::audio::SampleBuffer;
|
|||
use symphonia::default::get_codecs;
|
||||
|
||||
pub enum SamplerCommand {
|
||||
Import
|
||||
}
|
||||
|
||||
impl TryFrom<&Arc<RwLock<JackClient>>> for SamplerTui {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub enum SequencerCommand {
|
|||
}
|
||||
|
||||
handle!(<Tui>|self:SequencerTui,input|SequencerCommand::execute_with_state(self, input));
|
||||
input_to_command!(SequencerCommand: <Tui>|state:SequencerTui,input|Some(match input.event() {
|
||||
input_to_command!(SequencerCommand: <Tui>|state:SequencerTui,input|match input.event() {
|
||||
// Transport: Play/pause
|
||||
key_pat!(Char(' ')) => Clock(if state.clock().is_stopped() {
|
||||
Play(None) } else { Pause(None) }),
|
||||
|
|
@ -95,7 +95,7 @@ input_to_command!(SequencerCommand: <Tui>|state:SequencerTui,input|Some(match in
|
|||
} else {
|
||||
return None
|
||||
}
|
||||
}));
|
||||
});
|
||||
command!(|self: SequencerCommand, state: SequencerTui|match self {
|
||||
Self::Phrases(cmd) => {
|
||||
let mut default = |cmd: PhrasesCommand|cmd.execute(&mut state.phrases).map(|x|x.map(Phrases));
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ command!(|self: FileBrowserCommand, state: PhraseListModel|{
|
|||
|
||||
input_to_command!(FileBrowserCommand:<Tui>|state:PhraseListModel,from|{
|
||||
if let Some(PhraseListMode::Import(_index, browser)) = state.phrases_mode() {
|
||||
Some(match from.event() {
|
||||
match from.event() {
|
||||
key_pat!(Up) => Select(
|
||||
browser.index.overflowing_sub(1).0.min(browser.len().saturating_sub(1))
|
||||
),
|
||||
|
|
@ -153,9 +153,9 @@ input_to_command!(FileBrowserCommand:<Tui>|state:PhraseListModel,from|{
|
|||
key_pat!(Backspace) => { todo!() },
|
||||
key_pat!(Esc) => Self::Cancel,
|
||||
_ => return None
|
||||
})
|
||||
}
|
||||
} else if let Some(PhraseListMode::Export(_index, browser)) = state.phrases_mode() {
|
||||
Some(match from.event() {
|
||||
match from.event() {
|
||||
key_pat!(Up) => Select(browser.index.overflowing_sub(1).0.min(browser.len())),
|
||||
key_pat!(Down) => Select(browser.index.saturating_add(1) % browser.len()),
|
||||
key_pat!(Right) => Chdir(browser.cwd.clone()),
|
||||
|
|
@ -165,7 +165,7 @@ input_to_command!(FileBrowserCommand:<Tui>|state:PhraseListModel,from|{
|
|||
key_pat!(Backspace) => { todo!() },
|
||||
key_pat!(Esc) => Self::Cancel,
|
||||
_ => return None
|
||||
})
|
||||
}
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ input_to_command!(FileBrowserCommand:<Tui>|state:PhraseListModel,from|{
|
|||
|
||||
input_to_command!(PhraseLengthCommand:<Tui>|state:PhraseListModel,from|{
|
||||
if let Some(PhraseListMode::Length(_, length, _)) = state.phrases_mode() {
|
||||
Some(match from.event() {
|
||||
match from.event() {
|
||||
key_pat!(Up) => Self::Inc,
|
||||
key_pat!(Down) => Self::Dec,
|
||||
key_pat!(Right) => Self::Next,
|
||||
|
|
@ -181,7 +181,7 @@ input_to_command!(PhraseLengthCommand:<Tui>|state:PhraseListModel,from|{
|
|||
key_pat!(Enter) => Self::Set(*length),
|
||||
key_pat!(Esc) => Self::Cancel,
|
||||
_ => return None
|
||||
})
|
||||
}
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,14 +99,12 @@ command!(|self:PhrasesCommand, state:PhraseListModel|{
|
|||
}
|
||||
});
|
||||
|
||||
input_to_command!(PhrasesCommand:<Tui>|state:PhraseListModel,input|{
|
||||
Some(match state.phrases_mode() {
|
||||
Some(PhraseListMode::Rename(..)) => Self::Rename(Rename::input_to_command(state, input)?),
|
||||
Some(PhraseListMode::Length(..)) => Self::Length(Length::input_to_command(state, input)?),
|
||||
Some(PhraseListMode::Import(..)) => Self::Import(Browse::input_to_command(state, input)?),
|
||||
Some(PhraseListMode::Export(..)) => Self::Export(Browse::input_to_command(state, input)?),
|
||||
_ => to_phrases_command(state, input)?
|
||||
})
|
||||
input_to_command!(PhrasesCommand:<Tui>|state:PhraseListModel,input|match state.phrases_mode() {
|
||||
Some(PhraseListMode::Rename(..)) => Self::Rename(Rename::input_to_command(state, input)?),
|
||||
Some(PhraseListMode::Length(..)) => Self::Length(Length::input_to_command(state, input)?),
|
||||
Some(PhraseListMode::Import(..)) => Self::Import(Browse::input_to_command(state, input)?),
|
||||
Some(PhraseListMode::Export(..)) => Self::Export(Browse::input_to_command(state, input)?),
|
||||
_ => to_phrases_command(state, input)?
|
||||
});
|
||||
|
||||
fn to_phrases_command (state: &PhraseListModel, input: &TuiInput) -> Option<PhrasesCommand> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue