mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
show phrase names again
This commit is contained in:
parent
4a8f5b267f
commit
888ed642d0
3 changed files with 58 additions and 48 deletions
|
|
@ -37,7 +37,7 @@ impl Track {
|
|||
Ok(Self {
|
||||
name: name.to_string(),
|
||||
midi_out: None,
|
||||
midi_out_buf: vec![vec![];16384],
|
||||
midi_out_buf: vec![Vec::with_capacity(16);16384],
|
||||
notes_in: [false;128],
|
||||
notes_out: [false;128],
|
||||
monitoring: false,
|
||||
|
|
@ -142,16 +142,18 @@ impl Track {
|
|||
(_usec0, _usecs): (usize, usize),
|
||||
period: f64,
|
||||
) {
|
||||
// Clear the section of the output buffer that we will be using
|
||||
for frame in &mut self.midi_out_buf[0..frames] {
|
||||
frame.clear();
|
||||
}
|
||||
// Emit "all notes off" at start of buffer if requested
|
||||
if self.reset {
|
||||
all_notes_off(&mut self.midi_out_buf);
|
||||
self.reset = false;
|
||||
} else if reset {
|
||||
all_notes_off(&mut self.midi_out_buf);
|
||||
if self.midi_out.is_some() {
|
||||
// Clear the section of the output buffer that we will be using
|
||||
for frame in &mut self.midi_out_buf[0..frames] {
|
||||
frame.clear();
|
||||
}
|
||||
// Emit "all notes off" at start of buffer if requested
|
||||
if self.reset {
|
||||
all_notes_off(&mut self.midi_out_buf);
|
||||
self.reset = false;
|
||||
} else if reset {
|
||||
all_notes_off(&mut self.midi_out_buf);
|
||||
}
|
||||
}
|
||||
// For highlighting keys and note repeat
|
||||
// Currently playing phrase
|
||||
|
|
@ -160,12 +162,14 @@ impl Track {
|
|||
) = (
|
||||
playing, started, self.sequence.and_then(|id|self.phrases.get_mut(id))
|
||||
) {
|
||||
phrase.process_out(
|
||||
&mut self.midi_out_buf,
|
||||
&mut self.notes_out,
|
||||
timebase,
|
||||
(frame0.saturating_sub(start_frame), frames, period)
|
||||
);
|
||||
if self.midi_out.is_some() {
|
||||
phrase.process_out(
|
||||
&mut self.midi_out_buf,
|
||||
&mut self.notes_out,
|
||||
timebase,
|
||||
(frame0.saturating_sub(start_frame), frames, period)
|
||||
);
|
||||
}
|
||||
// Monitor and record input
|
||||
if input.is_some() && (self.recording || self.monitoring) {
|
||||
// For highlighting keys and note repeat
|
||||
|
|
@ -201,7 +205,7 @@ impl Track {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if input.is_some() && self.monitoring {
|
||||
} else if input.is_some() && self.midi_out.is_some() && self.monitoring {
|
||||
for (frame, event, bytes) in parse_midi_input(input.unwrap()) {
|
||||
self.process_monitor_event(frame, &event, bytes)
|
||||
}
|
||||
|
|
@ -241,22 +245,20 @@ impl Track {
|
|||
}
|
||||
|
||||
impl App {
|
||||
|
||||
pub fn new_track_name (&self) -> String {
|
||||
format!("Track {}", self.tracks.len() + 1)
|
||||
}
|
||||
pub fn add_track (
|
||||
&mut self,
|
||||
name: Option<&str>,
|
||||
) -> Usually<&mut Track> {
|
||||
|
||||
pub fn add_track (&mut self, name: Option<&str>) -> Usually<&mut Track> {
|
||||
let name = name.ok_or_else(||self.new_track_name())?;
|
||||
self.tracks.push(Track::new(&name, None, None)?);
|
||||
self.track_cursor = self.tracks.len();
|
||||
Ok(&mut self.tracks[self.track_cursor - 1])
|
||||
}
|
||||
|
||||
pub fn add_track_with_cb (
|
||||
&mut self,
|
||||
name: Option<&str>,
|
||||
init: impl FnOnce(&Client, &mut Track)->Usually<()>,
|
||||
&mut self, name: Option<&str>, init: impl FnOnce(&Client, &mut Track)->Usually<()>,
|
||||
) -> Usually<&mut Track> {
|
||||
let name = name.ok_or_else(||self.new_track_name())?;
|
||||
let mut track = Track::new(&name, None, None)?;
|
||||
|
|
@ -265,16 +267,19 @@ impl App {
|
|||
self.track_cursor = self.tracks.len();
|
||||
Ok(&mut self.tracks[self.track_cursor - 1])
|
||||
}
|
||||
|
||||
pub fn track (&self) -> Option<(usize, &Track)> {
|
||||
match self.track_cursor { 0 => None, _ => {
|
||||
let id = self.track_cursor as usize - 1;
|
||||
self.tracks.get(id).map(|t|(id, t))
|
||||
} }
|
||||
}
|
||||
|
||||
pub fn track_mut (&mut self) -> Option<(usize, &mut Track)> {
|
||||
match self.track_cursor { 0 => None, _ => {
|
||||
let id = self.track_cursor as usize - 1;
|
||||
self.tracks.get_mut(id).map(|t|(id, t))
|
||||
} }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue