mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-11 14:16:42 +01:00
basic midi import example
This commit is contained in:
parent
35944cf684
commit
f5b1f495ad
8 changed files with 114 additions and 66 deletions
|
|
@ -11,9 +11,9 @@ pub trait HasPhrase: ClockApi {
|
|||
fn reset (&self) -> bool;
|
||||
fn reset_mut (&mut self) -> &mut bool;
|
||||
|
||||
fn phrase (&self)
|
||||
fn play_phrase (&self)
|
||||
-> &Option<(Instant, Option<Arc<RwLock<Phrase>>>)>;
|
||||
fn phrase_mut (&mut self)
|
||||
fn play_phrase_mut (&mut self)
|
||||
-> &mut Option<(Instant, Option<Arc<RwLock<Phrase>>>)>;
|
||||
|
||||
fn next_phrase (&self)
|
||||
|
|
@ -29,7 +29,7 @@ pub trait HasPhrase: ClockApi {
|
|||
*self.reset_mut() = true;
|
||||
}
|
||||
fn pulses_since_start (&self) -> Option<f64> {
|
||||
if let Some((started, Some(_))) = self.phrase().as_ref() {
|
||||
if let Some((started, Some(_))) = self.play_phrase().as_ref() {
|
||||
Some(self.current().pulse.get() - started.pulse.get())
|
||||
} else {
|
||||
None
|
||||
|
|
@ -71,7 +71,7 @@ pub trait MidiInputApi: ClockApi + HasPhrase {
|
|||
let sample0 = scope.last_frame_time() as usize;
|
||||
// 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()) {
|
||||
if let (true, Some((started, ref phrase))) = (self.is_rolling(), self.play_phrase().clone()) {
|
||||
let start = started.sample.get() as usize;
|
||||
let quant = self.quant().get();
|
||||
let timebase = self.timebase().clone();
|
||||
|
|
@ -166,8 +166,8 @@ pub trait MidiOutputApi: ClockApi + HasPhrase {
|
|||
let sample0 = scope.last_frame_time() as usize;
|
||||
let samples = scope.n_frames() as usize;
|
||||
// If no phrase is playing, prepare for switchover immediately
|
||||
next = self.phrase().is_none();
|
||||
let phrase = self.phrase();
|
||||
next = self.play_phrase().is_none();
|
||||
let phrase = self.play_phrase();
|
||||
let started0 = self.transport_offset();
|
||||
let timebase = self.timebase();
|
||||
let notes_out = self.notes_out();
|
||||
|
|
@ -241,7 +241,7 @@ pub trait MidiOutputApi: ClockApi + HasPhrase {
|
|||
let skipped = sample0 - start;
|
||||
// Switch over to enqueued phrase
|
||||
let started = Instant::from_sample(&self.timebase(), start as f64);
|
||||
*self.phrase_mut() = Some((started, phrase.clone()));
|
||||
*self.play_phrase_mut() = Some((started, phrase.clone()));
|
||||
// Unset enqueuement (TODO: where to implement looping?)
|
||||
*self.next_phrase_mut() = None
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue