mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: focus refactor, e40
This commit is contained in:
parent
94a16b9dbc
commit
364769a2e0
10 changed files with 198 additions and 279 deletions
|
|
@ -39,7 +39,7 @@ pub trait HasPhrase: ClockApi {
|
|||
|
||||
pub trait MidiInputApi: ClockApi + HasPhrase {
|
||||
fn midi_ins (&self) -> &Vec<Port<MidiIn>>;
|
||||
fn midi_ins_mut (&self) -> &mut Vec<Port<MidiIn>>;
|
||||
fn midi_ins_mut (&mut self) -> &mut Vec<Port<MidiIn>>;
|
||||
fn has_midi_ins (&self) -> bool {
|
||||
self.midi_ins().len() > 0
|
||||
}
|
||||
|
|
@ -69,32 +69,34 @@ pub trait MidiInputApi: ClockApi + HasPhrase {
|
|||
midi_buf: &mut Vec<Vec<Vec<u8>>>,
|
||||
) {
|
||||
let sample0 = scope.last_frame_time() as usize;
|
||||
if let (true, Some((started, phrase))) = (self.is_rolling(), self.phrase()) {
|
||||
let start = started.sample.get() as usize;
|
||||
let quant = self.quant().get();
|
||||
// For highlighting keys and note repeat
|
||||
let mut notes_in = self.notes_in().write().unwrap();
|
||||
// Record from each input
|
||||
// For highlighting keys and note repeat
|
||||
let notes_in = self.notes_in().clone();
|
||||
if let (true, Some((started, ref phrase))) = (self.is_rolling(), self.phrase().clone()) {
|
||||
let start = started.sample.get() as usize;
|
||||
let quant = self.quant().get();
|
||||
let timebase = self.timebase().clone();
|
||||
let monitoring = self.monitoring();
|
||||
let recording = self.recording();
|
||||
for input in self.midi_ins_mut().iter() {
|
||||
for (sample, event, bytes) in parse_midi_input(input.iter(scope)) {
|
||||
if let LiveEvent::Midi { message, .. } = event {
|
||||
if self.monitoring() {
|
||||
if monitoring {
|
||||
midi_buf[sample].push(bytes.to_vec())
|
||||
}
|
||||
if self.recording() {
|
||||
if recording {
|
||||
if let Some(phrase) = phrase {
|
||||
let mut phrase = phrase.write().unwrap();
|
||||
let length = phrase.length;
|
||||
phrase.record_event({
|
||||
let sample = (sample0 + sample - start) as f64;
|
||||
let pulse = self.timebase().samples_to_pulse(sample);
|
||||
let pulse = timebase.samples_to_pulse(sample);
|
||||
let quantized = (pulse / quant).round() * quant;
|
||||
let looped = quantized as usize % length;
|
||||
looped
|
||||
}, message);
|
||||
}
|
||||
}
|
||||
update_keys(&mut notes_in, &message);
|
||||
update_keys(&mut*notes_in.write().unwrap(), &message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -109,12 +111,13 @@ pub trait MidiInputApi: ClockApi + HasPhrase {
|
|||
scope: &ProcessScope,
|
||||
midi_buf: &mut Vec<Vec<Vec<u8>>>,
|
||||
) {
|
||||
let mut notes_in = self.notes_in().write().unwrap();
|
||||
// For highlighting keys and note repeat
|
||||
let notes_in = self.notes_in().clone();
|
||||
for input in self.midi_ins_mut().iter() {
|
||||
for (sample, event, bytes) in parse_midi_input(input.iter(scope)) {
|
||||
if let LiveEvent::Midi { message, .. } = event {
|
||||
midi_buf[sample].push(bytes.to_vec());
|
||||
update_keys(&mut notes_in, &message);
|
||||
update_keys(&mut*notes_in.write().unwrap(), &message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue