mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
phrase 0; stop all; loop_on->looped; remove trailers
This commit is contained in:
parent
ce523d9e45
commit
775fea2c08
8 changed files with 23 additions and 14 deletions
|
|
@ -117,7 +117,7 @@ pub struct Phrase {
|
|||
/// Notes in phrase
|
||||
pub notes: PhraseData,
|
||||
/// Whether to loop the phrase or play it once
|
||||
pub loop_on: bool,
|
||||
pub looped: bool,
|
||||
/// Start of loop
|
||||
pub loop_start: usize,
|
||||
/// Length of loop
|
||||
|
|
@ -134,7 +134,7 @@ pub type PhraseData = Vec<Vec<MidiMessage>>;
|
|||
impl Phrase {
|
||||
pub fn new (
|
||||
name: impl AsRef<str>,
|
||||
loop_on: bool,
|
||||
looped: bool,
|
||||
length: usize,
|
||||
notes: Option<PhraseData>,
|
||||
color: Option<ItemPalette>,
|
||||
|
|
@ -145,7 +145,7 @@ impl Phrase {
|
|||
ppq: PPQ,
|
||||
length,
|
||||
notes: notes.unwrap_or(vec![Vec::with_capacity(16);length]),
|
||||
loop_on,
|
||||
looped,
|
||||
loop_start: 0,
|
||||
loop_length: length,
|
||||
percussive: true,
|
||||
|
|
@ -161,7 +161,7 @@ impl Phrase {
|
|||
clone.uuid = uuid::Uuid::new_v4();
|
||||
clone
|
||||
}
|
||||
pub fn toggle_loop (&mut self) { self.loop_on = !self.loop_on; }
|
||||
pub fn toggle_loop (&mut self) { self.looped = !self.looped; }
|
||||
pub fn record_event (&mut self, pulse: usize, message: MidiMessage) {
|
||||
if pulse >= self.length { panic!("extend phrase first") }
|
||||
self.notes[pulse].push(message);
|
||||
|
|
@ -180,7 +180,16 @@ impl Phrase {
|
|||
|
||||
impl Default for Phrase {
|
||||
fn default () -> Self {
|
||||
Self::new("null", false, 0, None, Some(ItemColor::from(Color::Rgb(0, 0, 0)).into()))
|
||||
Self::new(
|
||||
"Stop",
|
||||
false,
|
||||
1,
|
||||
Some(vec![vec![MidiMessage::Controller {
|
||||
controller: 123.into(),
|
||||
value: 0.into()
|
||||
}]]),
|
||||
Some(ItemColor::from(Color::Rgb(32, 32, 32)).into())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ impl std::fmt::Debug for PhraseEditorModel {
|
|||
pub struct PhraseEditStatus<'a>(pub &'a PhraseEditorModel);
|
||||
render!(|self:PhraseEditStatus<'a>|row!(|add|{
|
||||
let (color, name, length, looped) = if let Some(phrase) = self.0.phrase().as_ref().map(|p|p.read().unwrap()) {
|
||||
(phrase.color, phrase.name.clone(), phrase.length, phrase.loop_on)
|
||||
(phrase.color, phrase.name.clone(), phrase.length, phrase.looped)
|
||||
} else {
|
||||
(ItemPalette::from(TuiTheme::g(64)), String::new(), 0, false)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ impl PhraseSelector {
|
|||
(time, name.clone(), color)
|
||||
} else if let Some((_, Some(phrase))) = state.play_phrase() {
|
||||
let phrase = phrase.read().unwrap();
|
||||
if phrase.loop_on {
|
||||
if phrase.looped {
|
||||
(" ".into(), phrase.name.clone(), phrase.color.clone())
|
||||
} else {
|
||||
(" ".into(), " ".into(), TuiTheme::g(64).into())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue