mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
fix quantized recording for good
This commit is contained in:
parent
f9fa24de0d
commit
e98c110dbe
4 changed files with 18 additions and 16 deletions
|
|
@ -45,23 +45,23 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}],
|
}],
|
||||||
[Char('l'), NONE, "loop_toggle", "toggle looping", |app: &mut App| {
|
[Char('l'), NONE, "loop_toggle", "toggle looping", |_app: &mut App| {
|
||||||
// TODO: This toggles the loop flag for the clip under the cursor.
|
// TODO: This toggles the loop flag for the clip under the cursor.
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}],
|
}],
|
||||||
[Char('['), NONE, "loop_start_dec", "move loop start back", |app: &mut App| {
|
[Char('['), NONE, "loop_start_dec", "move loop start back", |_app: &mut App| {
|
||||||
// TODO: This moves the loop start to the previous quant.
|
// TODO: This moves the loop start to the previous quant.
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}],
|
}],
|
||||||
[Char(']'), NONE, "loop_start_inc", "move loop start forward", |app: &mut App| {
|
[Char(']'), NONE, "loop_start_inc", "move loop start forward", |_app: &mut App| {
|
||||||
// TODO: This moves the loop start to the next quant.
|
// TODO: This moves the loop start to the next quant.
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}],
|
}],
|
||||||
[Char('{'), NONE, "loop_end_dec", "move loop end back", |app: &mut App| {
|
[Char('{'), NONE, "loop_end_dec", "move loop end back", |_app: &mut App| {
|
||||||
// TODOO: This moves the loop end to the previous quant.
|
// TODOO: This moves the loop end to the previous quant.
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}],
|
}],
|
||||||
[Char('}'), NONE, "loop_end_inc", "move loop end forward", |app: &mut App| {
|
[Char('}'), NONE, "loop_end_inc", "move loop end forward", |_app: &mut App| {
|
||||||
// TODO: This moves the loop end to the next quant.
|
// TODO: This moves the loop end to the next quant.
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}],
|
}],
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ impl Timebase {
|
||||||
#[inline] pub fn pulse_per_frame (&self) -> f64 {
|
#[inline] pub fn pulse_per_frame (&self) -> f64 {
|
||||||
self.usec_per_pulse() / self.usec_per_frame() as f64
|
self.usec_per_pulse() / self.usec_per_frame() as f64
|
||||||
}
|
}
|
||||||
#[inline] fn usec_per_pulse (&self) -> f64 {
|
#[inline] pub fn usec_per_pulse (&self) -> f64 {
|
||||||
self.usec_per_beat() / self.ppq() as f64
|
self.usec_per_beat() / self.ppq() as f64
|
||||||
}
|
}
|
||||||
#[inline] pub fn pulse_to_frame (&self, pulses: f64) -> f64 {
|
#[inline] pub fn pulse_to_frame (&self, pulses: f64) -> f64 {
|
||||||
|
|
|
||||||
|
|
@ -159,19 +159,21 @@ impl Track {
|
||||||
if self.recording || self.monitoring {
|
if self.recording || self.monitoring {
|
||||||
// For highlighting keys
|
// For highlighting keys
|
||||||
let notes_on = &mut self.notes_on;
|
let notes_on = &mut self.notes_on;
|
||||||
for (time, event, bytes) in parse_midi_input(input) {
|
for (frame, event, bytes) in parse_midi_input(input) {
|
||||||
match event {
|
match event {
|
||||||
LiveEvent::Midi { message, .. } => {
|
LiveEvent::Midi { message, .. } => {
|
||||||
if monitoring {
|
if monitoring {
|
||||||
self.midi_out_buf[time].push(bytes.to_vec())
|
self.midi_out_buf[frame].push(bytes.to_vec())
|
||||||
}
|
}
|
||||||
if recording {
|
if recording {
|
||||||
phrase.as_mut().map(|p|p.record_event({
|
if let Some((start_frame, _)) = started {
|
||||||
let pulse = timebase.frame_to_pulse((frame0 + time) as f64) as usize;
|
phrase.as_mut().map(|p|p.record_event({
|
||||||
let pulse = (pulse / quant) * quant;
|
let pulse = timebase.frame_to_pulse((frame0 + frame - start_frame) as f64);
|
||||||
let pulse = pulse % p.length;
|
let quantized = (pulse / quant as f64).round() as usize * quant;
|
||||||
pulse
|
let looped = quantized % p.length;
|
||||||
}, message));
|
looped
|
||||||
|
}, message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
match message {
|
match message {
|
||||||
MidiMessage::NoteOn { key, .. } => {
|
MidiMessage::NoteOn { key, .. } => {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ impl<'a> SceneGridViewVertical<'a> {
|
||||||
lozenge_right(self.buf, x + width - 1, y, height, style);
|
lozenge_right(self.buf, x + width - 1, y, height, style);
|
||||||
}
|
}
|
||||||
let bg_color = if self.focused && self.entered {
|
let bg_color = if self.focused && self.entered {
|
||||||
Color::Rgb(30, 75, 25)
|
Color::Rgb(30, 90, 25)
|
||||||
} else if self.focused {
|
} else if self.focused {
|
||||||
Color::Rgb(25, 60, 15)
|
Color::Rgb(25, 60, 15)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -60,7 +60,6 @@ impl<'a> SceneGridViewVertical<'a> {
|
||||||
if x2 >= x + width {
|
if x2 >= x + width {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
let style = Some(highlight(self.focused, focus_column).bold());
|
|
||||||
let w = (title.len() as u16).max(10);
|
let w = (title.len() as u16).max(10);
|
||||||
fill_bg(
|
fill_bg(
|
||||||
&mut self.buf,
|
&mut self.buf,
|
||||||
|
|
@ -76,6 +75,7 @@ impl<'a> SceneGridViewVertical<'a> {
|
||||||
} else if i < columns.len() {
|
} else if i < columns.len() {
|
||||||
self.clips(x2+1, y2+2, i - 1);
|
self.clips(x2+1, y2+2, i - 1);
|
||||||
};
|
};
|
||||||
|
let style = Some(highlight(self.focused, focus_column).bold());
|
||||||
title.blit(self.buf, x2+1, y2, style);
|
title.blit(self.buf, x2+1, y2, style);
|
||||||
x2 = x2 + w + 3;
|
x2 = x2 + w + 3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue