wip: reenable sequencer, pt.2

This commit is contained in:
🪞👃🪞 2024-09-19 02:36:55 +03:00
parent 7063ae90d1
commit e1eef9e2e9
2 changed files with 59 additions and 78 deletions

View file

@ -80,8 +80,8 @@ impl Content for ArrangerStandalone<Tui> {
add(&self.transport)?;
if let Some(direction) = self.show_sequencer {
add(&Split::new(direction, |add|{
add(&self.arranger)?;
add(&Min::Y(10, self.arranger.sequencer().map(
add(&Shrink::Y(20, &self.arranger as &dyn Widget<Engine = Tui>))?;
add(&Min::Y(20, self.arranger.sequencer().map(
|x|x as &dyn Widget<Engine = Tui>
)))?;
Ok(())

View file

@ -1566,97 +1566,81 @@ pub(crate) fn keys_vert () -> Buffer {
///////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceName<'a>(&'a Sequencer<Tui>);
impl<'a> Widget for SequenceName<'a> {
impl<'a> Content for SequenceName<'a> {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let [x, y, ..] = to.area();
let frame = [x, y, 10, 4];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
to.blit(&"Name:", x + 1, y + 1, Some(STYLE_LABEL));
to.blit(&*self.0.name.read().unwrap(), x + 1, y + 2, Some(STYLE_VALUE));
Ok(())
fn content (&self) -> impl Widget<Engine = Tui> {
Min::XY(10, 4, Split::down(|add|{
let name: &str = &*self.0.name.read().unwrap();
add(&"Name")?;
add(&name)?;
//Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
Ok(())
}))
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceRange;
impl Widget for SequenceRange {
impl Content for SequenceRange {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let [x, y, ..] = to.area();
let frame = [x, y, 10, 6];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
to.blit(&"Start: ", x + 1, y + 1, Some(STYLE_LABEL));
to.blit(&" 1.1.1", x + 1, y + 2, Some(STYLE_VALUE));
to.blit(&"End: ", x + 1, y + 3, Some(STYLE_LABEL));
to.blit(&" 2.1.1", x + 1, y + 4, Some(STYLE_VALUE));
Ok(())
fn content (&self) -> impl Widget<Engine = Tui> {
Min::XY(10, 6, Split::down(|add|{
add(&"Start: ")?;//Some(STYLE_LABEL));
add(&" 1.1.1")?;//Some(STYLE_VALUE));
add(&"End: ")?;//Some(STYLE_LABEL));
add(&" 2.1.1")?;//Some(STYLE_VALUE));
//Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
Ok(())
}))
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceLoopRange;
impl Widget for SequenceLoopRange {
impl Content for SequenceLoopRange {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let [x, y, ..] = to.area();
let range = [x, y, 10, 7];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
to.blit(&"Loop [ ]", x + 1, y + 1, Some(STYLE_LABEL));
to.blit(&"From: ", x + 1, y + 2, Some(STYLE_LABEL));
to.blit(&" 1.1.1", x + 1, y + 3, Some(STYLE_VALUE));
to.blit(&"Length: ", x + 1, y + 4, Some(STYLE_LABEL));
to.blit(&" 1.0.0", x + 1, y + 5, Some(STYLE_VALUE));
Ok(())
fn content (&self) -> impl Widget<Engine = Tui> {
Min::XY(10, 7, Split::down(|add|{
//Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
add(&"Loop [ ]")?;//Some(STYLE_LABEL));
add(&"From: ")?;//Some(STYLE_LABEL));
add(&" 1.1.1")?;//Some(STYLE_VALUE));
add(&"Length: ")?;//Some(STYLE_LABEL));
add(&" 1.0.0")?;//Some(STYLE_VALUE));
Ok(())
}))
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceNoteRange;
impl Widget for SequenceNoteRange {
impl Content for SequenceNoteRange {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let [x, y, ..] = to.area();
let range = [x, y, 10, 9];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
to.blit(&"Notes: ", x + 1, y + 1, Some(STYLE_LABEL));
to.blit(&"C#0-C#9 ", x + 1, y + 2, Some(STYLE_VALUE));
to.blit(&"[ /2 ]", x + 1, y + 3, Some(STYLE_LABEL));
to.blit(&"[ x2 ]", x + 1, y + 4, Some(STYLE_LABEL));
to.blit(&"[ Rev ]", x + 1, y + 5, Some(STYLE_LABEL));
to.blit(&"[ Inv ]", x + 1, y + 6, Some(STYLE_LABEL));
to.blit(&"[ Dup ]", x + 1, y + 7, Some(STYLE_LABEL));
Ok(())
fn content (&self) -> impl Widget<Engine = Tui> {
Min::XY(10, 9, Split::down(|add|{
//Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
add(&"Notes: ")?;//Some(STYLE_LABEL));
add(&"C#0-C#9 ")?;//Some(STYLE_VALUE));
add(&"[ /2 ]")?;//Some(STYLE_LABEL));
add(&"[ x2 ]")?;//Some(STYLE_LABEL));
add(&"[ Rev ]")?;//Some(STYLE_LABEL));
add(&"[ Inv ]")?;//Some(STYLE_LABEL));
add(&"[ Dup ]")?;//Some(STYLE_LABEL));
Ok(())
}))
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceKeys<'a>(&'a Sequencer<Tui>);
impl<'a> Widget for SequenceKeys<'a> {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
Ok(Some([32,4]))
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let area = to.area();
@ -1677,11 +1661,10 @@ impl<'a> Widget for SequenceKeys<'a> {
///////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceNotes<'a>(&'a Sequencer<Tui>);
impl<'a> Widget for SequenceNotes<'a> {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
Ok(Some([32,4]))
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let area = to.area();
@ -1712,11 +1695,10 @@ impl<'a> Widget for SequenceNotes<'a> {
///////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceCursor<'a>(&'a Sequencer<Tui>);
impl<'a> Widget for SequenceCursor<'a> {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
Ok(Some([1,1]))
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let area = to.area();
@ -1736,11 +1718,10 @@ impl<'a> Widget for SequenceCursor<'a> {
///////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceZoom<'a>(&'a Sequencer<Tui>);
impl<'a> Widget for SequenceZoom<'a> {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
Ok(Some([10,1]))
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let area = to.area();
@ -1752,12 +1733,13 @@ impl<'a> Widget for SequenceZoom<'a> {
}
}
struct SequenceTimer<'a>(&'a Sequencer<Tui>, Arc<RwLock<Phrase>>);
//////////////////////////////////////////////////////////////////////////////////////////////////
struct SequenceTimer<'a>(&'a Sequencer<Tui>, Arc<RwLock<Phrase>>);
impl<'a> Widget for SequenceTimer<'a> {
type Engine = Tui;
fn layout (&self, _to: [u16;2]) -> Perhaps<[u16;2]> {
todo!()
Ok(Some([32,2]))
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let area = to.area();
@ -1779,13 +1761,14 @@ impl<'a> Widget for SequenceTimer<'a> {
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
/// A collection of phrases to play on each track.
#[derive(Default)]
pub struct Scene {
pub name: Arc<RwLock<String>>,
pub clips: Vec<Option<usize>>,
}
impl Scene {
pub fn from_edn <'a, 'e> (args: &[Edn<'e>]) -> Usually<Self> {
let mut name = None;
@ -1843,6 +1826,8 @@ impl Scene {
///////////////////////////////////////////////////////////////////////////////////////////////////
/// A collection of MIDI messages.
pub type PhraseData = Vec<Vec<MidiMessage>>;
#[derive(Debug)]
/// A MIDI sequence.
pub struct Phrase {
@ -1853,15 +1838,11 @@ pub struct Phrase {
/// All notes are displayed with minimum length
pub percussive: bool
}
pub type PhraseData = Vec<Vec<MidiMessage>>;
impl Default for Phrase {
fn default () -> Self {
Self::new("", 0, None)
}
}
impl Phrase {
pub fn new (name: &str, length: usize, notes: Option<PhraseData>) -> Self {
Self {