mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +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
|
|
@ -159,19 +159,21 @@ impl Track {
|
|||
if self.recording || self.monitoring {
|
||||
// For highlighting keys
|
||||
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 {
|
||||
LiveEvent::Midi { message, .. } => {
|
||||
if monitoring {
|
||||
self.midi_out_buf[time].push(bytes.to_vec())
|
||||
self.midi_out_buf[frame].push(bytes.to_vec())
|
||||
}
|
||||
if recording {
|
||||
phrase.as_mut().map(|p|p.record_event({
|
||||
let pulse = timebase.frame_to_pulse((frame0 + time) as f64) as usize;
|
||||
let pulse = (pulse / quant) * quant;
|
||||
let pulse = pulse % p.length;
|
||||
pulse
|
||||
}, message));
|
||||
if let Some((start_frame, _)) = started {
|
||||
phrase.as_mut().map(|p|p.record_event({
|
||||
let pulse = timebase.frame_to_pulse((frame0 + frame - start_frame) as f64);
|
||||
let quantized = (pulse / quant as f64).round() as usize * quant;
|
||||
let looped = quantized % p.length;
|
||||
looped
|
||||
}, message));
|
||||
}
|
||||
}
|
||||
match message {
|
||||
MidiMessage::NoteOn { key, .. } => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue