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({
|
||||
let app = app.clone();
|
||||
move|c: &Client, s: &ProcessScope|{
|
||||
app.lock().unwrap().process(c, s)
|
||||
//app.lock().unwrap().process(c, s)
|
||||
Control::Continue
|
||||
}
|
||||
}) as BoxedProcessHandler)
|
||||
)?)
|
||||
|
|
|
|||
29
src/main.rs
29
src/main.rs
|
|
@ -28,9 +28,6 @@ pub fn main () -> Usually<()> {
|
|||
state.scenes = vec![
|
||||
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![
|
||||
Track::new("Drums", &state.timebase, Some(vec![
|
||||
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!(44, "Hihat", "/home/user/Lab/Music/pak/chh.wav"),
|
||||
])))?.boxed(),
|
||||
]), None)?,
|
||||
]), Some(vec![
|
||||
Phrase::new("4 kicks", state.timebase.ppq() as usize * 4, None),
|
||||
]))?,
|
||||
];
|
||||
state.jack = Some(jack_run("tek", &app)?);
|
||||
Ok(())
|
||||
|
|
@ -84,14 +83,14 @@ render!(App |self, buf, area| {
|
|||
|
||||
y = y + ChainView {
|
||||
focused: true,
|
||||
chain: None
|
||||
chain: Some(&self.tracks[0].chain),
|
||||
}.render(buf, Rect { x, y, width, height: height / 3 })?.height;
|
||||
|
||||
y = y + SequencerView {
|
||||
focused: true,
|
||||
ppq: self.timebase.ppq() as usize,
|
||||
track: None,
|
||||
phrase: None,
|
||||
track: Some(&self.tracks[0]),
|
||||
phrase: Some(&self.tracks[0].sequencer.phrases[0]),
|
||||
}.render(buf, Rect { x, y, width, height })?.height;
|
||||
|
||||
if let Some(ref modal) = self.modal {
|
||||
|
|
@ -114,7 +113,8 @@ handle!(App |self, e| {
|
|||
}
|
||||
handle_keymap(self, e, keymap!(App {
|
||||
[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],
|
||||
[Down, NONE, "cursor_down", "move cursor down", cursor_down],
|
||||
[Left, NONE, "cursor_left", "move cursor left", cursor_left],
|
||||
|
|
@ -124,9 +124,6 @@ handle!(App |self, e| {
|
|||
[Delete, CONTROL, "delete", "delete track", delete],
|
||||
[Char('d'), CONTROL, "duplicate", "duplicate scene or track", duplicate],
|
||||
[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('r'), NONE, "record_toggle", "toggle recording", record_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 activate (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
fn rename (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
fn add_track (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
fn delete_track (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
fn add_track (app: &mut App) -> Usually<bool> {
|
||||
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_down (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
fn cursor_left (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
|
|
|
|||
|
|
@ -16,23 +16,23 @@ impl Track {
|
|||
) -> Usually<Self> {
|
||||
let sequencer = Sequencer::new(&name, tempo, phrases)?;
|
||||
let chain = Chain::new(&name, devices)?;
|
||||
let (client, _status) = Client::new("init", ClientOptions::NO_START_SERVER)?;
|
||||
{
|
||||
if let (Some(output), Some(input)) = (
|
||||
sequencer.midi_outs()?.get(0).clone(),
|
||||
if let Some(item) = chain.items.get(0) {
|
||||
if let Some(port) = item.midi_ins()?.get(0) {
|
||||
Some(port.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
) {
|
||||
client.connect_ports_by_name(&output, &input)?;
|
||||
}
|
||||
}
|
||||
//let (client, _status) = Client::new("init", ClientOptions::NO_START_SERVER)?;
|
||||
//{
|
||||
//if let (Some(output), Some(input)) = (
|
||||
//sequencer.midi_outs()?.get(0).clone(),
|
||||
//if let Some(item) = chain.items.get(0) {
|
||||
//if let Some(port) = item.midi_ins()?.get(0) {
|
||||
//Some(port.clone())
|
||||
//} else {
|
||||
//None
|
||||
//}
|
||||
//} else {
|
||||
//None
|
||||
//}
|
||||
//) {
|
||||
//client.connect_ports_by_name(&output, &input)?;
|
||||
//}
|
||||
//}
|
||||
Ok(Self { name: name.to_string(), sequencer, chain })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,67 @@ pub struct ChainView<'a> {
|
|||
|
||||
impl<'a> Render for ChainView<'a> {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let style = Some(Style::default().green().dim());
|
||||
if self.focused {
|
||||
let Rect { x, y, width, height} = area;
|
||||
lozenge_left(buf, x, y, height, style);
|
||||
lozenge_right(buf, x + width - 1, y, height, style);
|
||||
};
|
||||
let style = Some(if self.focused {
|
||||
Style::default().green()
|
||||
} else {
|
||||
Style::default().green().dim()
|
||||
});
|
||||
let (area, _plugins) = if let Some(ref chain) = self.chain {
|
||||
draw_as_row(&*chain, buf, area, style)?
|
||||
} else {
|
||||
(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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
-> Usually<Rect>
|
||||
{
|
||||
|
|
@ -59,56 +105,6 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
|||
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 (
|
||||
state: &Chain, buf: &mut Buffer, area: Rect, selected: Option<Style>
|
||||
) -> Usually<Rect> {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl<'a> SceneGridView<'a> {
|
|||
let w = (title.len() as u16).max(10) + 3;
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ impl<'a> SceneGridView<'a> {
|
|||
}
|
||||
let hi = (0 == self.cursor.0) &&
|
||||
(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)
|
||||
} else {
|
||||
Style::default().dim()
|
||||
|
|
@ -130,7 +130,7 @@ impl<'a> SceneGridView<'a> {
|
|||
format!("????")
|
||||
}
|
||||
} else {
|
||||
format!(" ·········")
|
||||
format!(" ·········")
|
||||
};
|
||||
label.blit(self.buf, x, y + index, style);
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ impl<'a> SceneGridView<'a> {
|
|||
}
|
||||
let hi = (track + 1 == self.cursor.0) &&
|
||||
(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)
|
||||
} else {
|
||||
Style::default().dim()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue