mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
compact
This commit is contained in:
parent
8c3cf53c67
commit
ea529b7734
5 changed files with 91 additions and 91 deletions
|
|
@ -16,7 +16,8 @@ pub fn jack_run <T> (name: &str, app: &Arc<Mutex<T>>) -> Usually<DynamicAsyncCli
|
||||||
ClosureProcessHandler::new(Box::new({
|
ClosureProcessHandler::new(Box::new({
|
||||||
let app = app.clone();
|
let app = app.clone();
|
||||||
move|c: &Client, s: &ProcessScope|{
|
move|c: &Client, s: &ProcessScope|{
|
||||||
app.lock().unwrap().process(c, s)
|
//app.lock().unwrap().process(c, s)
|
||||||
|
Control::Continue
|
||||||
}
|
}
|
||||||
}) as BoxedProcessHandler)
|
}) as BoxedProcessHandler)
|
||||||
)?)
|
)?)
|
||||||
|
|
|
||||||
29
src/main.rs
29
src/main.rs
|
|
@ -28,9 +28,6 @@ pub fn main () -> Usually<()> {
|
||||||
state.scenes = vec![
|
state.scenes = vec![
|
||||||
Scene::new("Intro", vec![None, None, None, None]),
|
Scene::new("Intro", vec![None, None, None, None]),
|
||||||
];
|
];
|
||||||
state.phrases = vec![
|
|
||||||
Phrase::new("4 kicks", state.timebase.ppq() as usize * 4, None),
|
|
||||||
];
|
|
||||||
state.tracks = vec![
|
state.tracks = vec![
|
||||||
Track::new("Drums", &state.timebase, Some(vec![
|
Track::new("Drums", &state.timebase, Some(vec![
|
||||||
Sampler::new("Sampler", Some(BTreeMap::from([
|
Sampler::new("Sampler", Some(BTreeMap::from([
|
||||||
|
|
@ -38,7 +35,9 @@ pub fn main () -> Usually<()> {
|
||||||
sample!(40, "Snare", "/home/user/Lab/Music/pak/sna.wav"),
|
sample!(40, "Snare", "/home/user/Lab/Music/pak/sna.wav"),
|
||||||
sample!(44, "Hihat", "/home/user/Lab/Music/pak/chh.wav"),
|
sample!(44, "Hihat", "/home/user/Lab/Music/pak/chh.wav"),
|
||||||
])))?.boxed(),
|
])))?.boxed(),
|
||||||
]), None)?,
|
]), Some(vec![
|
||||||
|
Phrase::new("4 kicks", state.timebase.ppq() as usize * 4, None),
|
||||||
|
]))?,
|
||||||
];
|
];
|
||||||
state.jack = Some(jack_run("tek", &app)?);
|
state.jack = Some(jack_run("tek", &app)?);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -84,14 +83,14 @@ render!(App |self, buf, area| {
|
||||||
|
|
||||||
y = y + ChainView {
|
y = y + ChainView {
|
||||||
focused: true,
|
focused: true,
|
||||||
chain: None
|
chain: Some(&self.tracks[0].chain),
|
||||||
}.render(buf, Rect { x, y, width, height: height / 3 })?.height;
|
}.render(buf, Rect { x, y, width, height: height / 3 })?.height;
|
||||||
|
|
||||||
y = y + SequencerView {
|
y = y + SequencerView {
|
||||||
focused: true,
|
focused: true,
|
||||||
ppq: self.timebase.ppq() as usize,
|
ppq: self.timebase.ppq() as usize,
|
||||||
track: None,
|
track: Some(&self.tracks[0]),
|
||||||
phrase: None,
|
phrase: Some(&self.tracks[0].sequencer.phrases[0]),
|
||||||
}.render(buf, Rect { x, y, width, height })?.height;
|
}.render(buf, Rect { x, y, width, height })?.height;
|
||||||
|
|
||||||
if let Some(ref modal) = self.modal {
|
if let Some(ref modal) = self.modal {
|
||||||
|
|
@ -114,7 +113,8 @@ handle!(App |self, e| {
|
||||||
}
|
}
|
||||||
handle_keymap(self, e, keymap!(App {
|
handle_keymap(self, e, keymap!(App {
|
||||||
[F(1), NONE, "toggle_help", "toggle help", toggle_help],
|
[F(1), NONE, "toggle_help", "toggle help", toggle_help],
|
||||||
|
[Tab, NONE, "focus_next", "focus next area", focus_next],
|
||||||
|
[Tab, SHIFT, "focus_prev", "focus previous area", focus_prev],
|
||||||
[Up, NONE, "cursor_up", "move cursor up", cursor_up],
|
[Up, NONE, "cursor_up", "move cursor up", cursor_up],
|
||||||
[Down, NONE, "cursor_down", "move cursor down", cursor_down],
|
[Down, NONE, "cursor_down", "move cursor down", cursor_down],
|
||||||
[Left, NONE, "cursor_left", "move cursor left", cursor_left],
|
[Left, NONE, "cursor_left", "move cursor left", cursor_left],
|
||||||
|
|
@ -124,9 +124,6 @@ handle!(App |self, e| {
|
||||||
[Delete, CONTROL, "delete", "delete track", delete],
|
[Delete, CONTROL, "delete", "delete track", delete],
|
||||||
[Char('d'), CONTROL, "duplicate", "duplicate scene or track", duplicate],
|
[Char('d'), CONTROL, "duplicate", "duplicate scene or track", duplicate],
|
||||||
[Enter, NONE, "activate", "activate item at cursor", activate],
|
[Enter, NONE, "activate", "activate item at cursor", activate],
|
||||||
|
|
||||||
[Tab, NONE, "focus_next", "focus next area", focus_next],
|
|
||||||
[Tab, SHIFT, "focus_prev", "focus previous area", focus_prev],
|
|
||||||
[Char(' '), NONE, "play_toggle", "play or pause", play_toggle],
|
[Char(' '), NONE, "play_toggle", "play or pause", play_toggle],
|
||||||
[Char('r'), NONE, "record_toggle", "toggle recording", record_toggle],
|
[Char('r'), NONE, "record_toggle", "toggle recording", record_toggle],
|
||||||
[Char('d'), NONE, "overdub_toggle", "toggle overdub", overdub_toggle],
|
[Char('d'), NONE, "overdub_toggle", "toggle overdub", overdub_toggle],
|
||||||
|
|
@ -143,8 +140,14 @@ fn delete (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||||
fn duplicate (_: &mut App) -> Usually<bool> { Ok(true) }
|
fn duplicate (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||||
fn activate (_: &mut App) -> Usually<bool> { Ok(true) }
|
fn activate (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||||
fn rename (_: &mut App) -> Usually<bool> { Ok(true) }
|
fn rename (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||||
fn add_track (_: &mut App) -> Usually<bool> { Ok(true) }
|
fn add_track (app: &mut App) -> Usually<bool> {
|
||||||
fn delete_track (_: &mut App) -> Usually<bool> { Ok(true) }
|
let name = format!("Track {}", app.tracks.len() + 1);
|
||||||
|
app.tracks.push(Track::new(&name, &app.timebase, None, None)?);
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
fn delete_track (_: &mut App) -> Usually<bool> {
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
fn cursor_up (_: &mut App) -> Usually<bool> { Ok(true) }
|
fn cursor_up (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||||
fn cursor_down (_: &mut App) -> Usually<bool> { Ok(true) }
|
fn cursor_down (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||||
fn cursor_left (_: &mut App) -> Usually<bool> { Ok(true) }
|
fn cursor_left (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||||
|
|
|
||||||
|
|
@ -16,23 +16,23 @@ impl Track {
|
||||||
) -> Usually<Self> {
|
) -> Usually<Self> {
|
||||||
let sequencer = Sequencer::new(&name, tempo, phrases)?;
|
let sequencer = Sequencer::new(&name, tempo, phrases)?;
|
||||||
let chain = Chain::new(&name, devices)?;
|
let chain = Chain::new(&name, devices)?;
|
||||||
let (client, _status) = Client::new("init", ClientOptions::NO_START_SERVER)?;
|
//let (client, _status) = Client::new("init", ClientOptions::NO_START_SERVER)?;
|
||||||
{
|
//{
|
||||||
if let (Some(output), Some(input)) = (
|
//if let (Some(output), Some(input)) = (
|
||||||
sequencer.midi_outs()?.get(0).clone(),
|
//sequencer.midi_outs()?.get(0).clone(),
|
||||||
if let Some(item) = chain.items.get(0) {
|
//if let Some(item) = chain.items.get(0) {
|
||||||
if let Some(port) = item.midi_ins()?.get(0) {
|
//if let Some(port) = item.midi_ins()?.get(0) {
|
||||||
Some(port.clone())
|
//Some(port.clone())
|
||||||
} else {
|
//} else {
|
||||||
None
|
//None
|
||||||
}
|
//}
|
||||||
} else {
|
//} else {
|
||||||
None
|
//None
|
||||||
}
|
//}
|
||||||
) {
|
//) {
|
||||||
client.connect_ports_by_name(&output, &input)?;
|
//client.connect_ports_by_name(&output, &input)?;
|
||||||
}
|
//}
|
||||||
}
|
//}
|
||||||
Ok(Self { name: name.to_string(), sequencer, chain })
|
Ok(Self { name: name.to_string(), sequencer, chain })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,67 @@ pub struct ChainView<'a> {
|
||||||
|
|
||||||
impl<'a> Render for ChainView<'a> {
|
impl<'a> Render for ChainView<'a> {
|
||||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||||
let style = Some(Style::default().green().dim());
|
let style = Some(if self.focused {
|
||||||
if self.focused {
|
Style::default().green()
|
||||||
let Rect { x, y, width, height} = area;
|
} else {
|
||||||
lozenge_left(buf, x, y, height, style);
|
Style::default().green().dim()
|
||||||
lozenge_right(buf, x + width - 1, y, height, style);
|
});
|
||||||
};
|
|
||||||
let (area, _plugins) = if let Some(ref chain) = self.chain {
|
let (area, _plugins) = if let Some(ref chain) = self.chain {
|
||||||
draw_as_row(&*chain, buf, area, style)?
|
draw_as_row(&*chain, buf, area, style)?
|
||||||
} else {
|
} else {
|
||||||
(area, vec![])
|
(area, vec![])
|
||||||
};
|
};
|
||||||
|
let Rect { x, y, width, height} = area;
|
||||||
|
lozenge_left(buf, x, y, height, style);
|
||||||
|
lozenge_right(buf, x + width - 1, y, height, style);
|
||||||
Ok(area)
|
Ok(area)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn draw_as_row (
|
||||||
|
state: &Chain, buf: &mut Buffer, area: Rect, style: Option<Style>
|
||||||
|
) -> Usually<(Rect, Vec<Rect>)> {
|
||||||
|
let Rect { mut x, y, width, height } = area;
|
||||||
|
let mut h = 0u16;
|
||||||
|
let mut frames = vec![];
|
||||||
|
for (i, device) in state.items.iter().enumerate() {
|
||||||
|
let x2 = 0u16;
|
||||||
|
let _y2 = 1u16;
|
||||||
|
//for port in device.midi_ins()?.iter() {
|
||||||
|
//port.blit(buf, x, y + y2, Some(Style::default()));
|
||||||
|
//x2 = x2.max(port.len() as u16);
|
||||||
|
//y2 = y2 + 1;
|
||||||
|
//}
|
||||||
|
//for port in device.audio_ins()?.iter() {
|
||||||
|
//port.blit(buf, x, y + y2, Some(Style::default()));
|
||||||
|
//x2 = x2.max(port.len() as u16);
|
||||||
|
//y2 = y2 + 1;
|
||||||
|
//}
|
||||||
|
let width = width.saturating_sub(x).saturating_sub(x2);
|
||||||
|
let frame = device.render(buf, Rect { x: x + x2, y, width, height })?;
|
||||||
|
lozenge_left(buf, x + x2, y, frame.height, style);
|
||||||
|
lozenge_right(buf, x + x2 + frame.width - 1, y, frame.height, style);
|
||||||
|
//let mut y2 = 1u16;
|
||||||
|
//for port in device.midi_outs()?.iter() {
|
||||||
|
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
|
||||||
|
//x2 = x2.max(port.len() as u16);
|
||||||
|
//y2 = y2 + 1;
|
||||||
|
//}
|
||||||
|
//for port in device.audio_outs()?.iter() {
|
||||||
|
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
|
||||||
|
//x2 = x2.max(port.len() as u16);
|
||||||
|
//y2 = y2 + 1;
|
||||||
|
//}
|
||||||
|
frames.push(frame);
|
||||||
|
h = h.max(frame.height);
|
||||||
|
x = x + frame.width;
|
||||||
|
}
|
||||||
|
let label = "[Add device…]";
|
||||||
|
label.blit(buf, x + 1, area.y + 1, Some(Style::default().dim()));
|
||||||
|
x = x + 1 + label.len() as u16 + 1;
|
||||||
|
Ok((Rect { x: area.x, y: area.y, width, height: h }, frames))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
||||||
-> Usually<Rect>
|
-> Usually<Rect>
|
||||||
{
|
{
|
||||||
|
|
@ -59,56 +105,6 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_as_row (
|
|
||||||
state: &Chain, buf: &mut Buffer, area: Rect, _: Option<Style>
|
|
||||||
) -> Usually<(Rect, Vec<Rect>)> {
|
|
||||||
let Rect { mut x, y, width, height } = area;
|
|
||||||
let mut h = 0u16;
|
|
||||||
let mut frames = vec![];
|
|
||||||
for (i, device) in state.items.iter().enumerate() {
|
|
||||||
let x2 = 0u16;
|
|
||||||
let _y2 = 1u16;
|
|
||||||
//for port in device.midi_ins()?.iter() {
|
|
||||||
//port.blit(buf, x, y + y2, Some(Style::default()));
|
|
||||||
//x2 = x2.max(port.len() as u16);
|
|
||||||
//y2 = y2 + 1;
|
|
||||||
//}
|
|
||||||
//for port in device.audio_ins()?.iter() {
|
|
||||||
//port.blit(buf, x, y + y2, Some(Style::default()));
|
|
||||||
//x2 = x2.max(port.len() as u16);
|
|
||||||
//y2 = y2 + 1;
|
|
||||||
//}
|
|
||||||
let width = width.saturating_sub(x).saturating_sub(x2);
|
|
||||||
let style = Some(if i == state.focus {
|
|
||||||
if state.focused {
|
|
||||||
Style::default().green().not_dim()
|
|
||||||
} else {
|
|
||||||
Style::default().green().dim()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Style::default().dim()
|
|
||||||
});
|
|
||||||
lozenge_left(buf, x + x2, y, height, style);
|
|
||||||
let frame = device.render(buf, Rect { x: x + x2, y, width, height })?;
|
|
||||||
lozenge_right(buf, x + x2 + frame.width - 1, y, height, style);
|
|
||||||
//let mut y2 = 1u16;
|
|
||||||
//for port in device.midi_outs()?.iter() {
|
|
||||||
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
|
|
||||||
//x2 = x2.max(port.len() as u16);
|
|
||||||
//y2 = y2 + 1;
|
|
||||||
//}
|
|
||||||
//for port in device.audio_outs()?.iter() {
|
|
||||||
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
|
|
||||||
//x2 = x2.max(port.len() as u16);
|
|
||||||
//y2 = y2 + 1;
|
|
||||||
//}
|
|
||||||
frames.push(frame);
|
|
||||||
h = h.max(frame.height);
|
|
||||||
x = x + frame.width;
|
|
||||||
}
|
|
||||||
Ok((Rect { x: area.x, y: area.y, width, height: h }, frames))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_as_column (
|
pub fn draw_as_column (
|
||||||
state: &Chain, buf: &mut Buffer, area: Rect, selected: Option<Style>
|
state: &Chain, buf: &mut Buffer, area: Rect, selected: Option<Style>
|
||||||
) -> Usually<Rect> {
|
) -> Usually<Rect> {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ impl<'a> SceneGridView<'a> {
|
||||||
let w = (title.len() as u16).max(10) + 3;
|
let w = (title.len() as u16).max(10) + 3;
|
||||||
x = x + w;
|
x = x + w;
|
||||||
}
|
}
|
||||||
"+Add track…".blit(self.buf, x + 2, y, Some(Style::default().dim()));
|
"[C-t] Add track…".blit(self.buf, x + 2, y + 1, Some(Style::default().dim()));
|
||||||
Ok(self.area)
|
Ok(self.area)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +100,7 @@ impl<'a> SceneGridView<'a> {
|
||||||
}
|
}
|
||||||
let hi = (0 == self.cursor.0) &&
|
let hi = (0 == self.cursor.0) &&
|
||||||
(self.scenes.len() + 1 == self.cursor.1);
|
(self.scenes.len() + 1 == self.cursor.1);
|
||||||
"+Add scene…".blit(self.buf, x, y + index as u16, Some(if hi {
|
"[Add scene…]".blit(self.buf, x, y + index as u16, Some(if hi {
|
||||||
self.highlight(true)
|
self.highlight(true)
|
||||||
} else {
|
} else {
|
||||||
Style::default().dim()
|
Style::default().dim()
|
||||||
|
|
@ -130,7 +130,7 @@ impl<'a> SceneGridView<'a> {
|
||||||
format!("????")
|
format!("????")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
format!(" ·········")
|
format!(" ·········")
|
||||||
};
|
};
|
||||||
label.blit(self.buf, x, y + index, style);
|
label.blit(self.buf, x, y + index, style);
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ impl<'a> SceneGridView<'a> {
|
||||||
}
|
}
|
||||||
let hi = (track + 1 == self.cursor.0) &&
|
let hi = (track + 1 == self.cursor.0) &&
|
||||||
(self.scenes.len() + 1 == self.cursor.1);
|
(self.scenes.len() + 1 == self.cursor.1);
|
||||||
" + Add clip".blit(self.buf, x, y + index as u16, Some(if hi {
|
"[Add clip…]".blit(self.buf, x, y + index as u16, Some(if hi {
|
||||||
self.highlight(true)
|
self.highlight(true)
|
||||||
} else {
|
} else {
|
||||||
Style::default().dim()
|
Style::default().dim()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue