mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
refactoring time representation into multuple traits
This commit is contained in:
parent
a25548c39c
commit
5a18a2023d
4 changed files with 149 additions and 72 deletions
|
|
@ -113,24 +113,28 @@ pub struct PhrasePlayer<E: Engine> {
|
|||
_engine: PhantomData<E>,
|
||||
/// Phrase being played
|
||||
pub phrase: Option<Arc<RwLock<Phrase>>>,
|
||||
/// Notes currently held at input
|
||||
pub notes_in: Arc<RwLock<[bool; 128]>>,
|
||||
/// Notes currently held at output
|
||||
pub notes_out: Arc<RwLock<[bool; 128]>>,
|
||||
/// Next phrase
|
||||
pub next_phrase: Option<Arc<RwLock<Phrase>>>,
|
||||
/// Current point in playing phrase
|
||||
pub now: Arc<AtomicUsize>,
|
||||
/// Frames remaining until switch to next phrase
|
||||
pub switch_at: Option<AtomicUsize>,
|
||||
/// Play input through output.
|
||||
pub monitoring: bool,
|
||||
/// Write input to sequence.
|
||||
pub recording: bool,
|
||||
/// Overdub input to sequence.
|
||||
pub overdub: bool,
|
||||
/// Send all notes off
|
||||
pub reset: bool, // TODO?: after Some(nframes)
|
||||
/// Output from current sequence.
|
||||
pub midi_out: Option<Port<MidiOut>>,
|
||||
/// MIDI output buffer
|
||||
pub midi_out_buf: Vec<Vec<Vec<u8>>>,
|
||||
/// Send all notes off
|
||||
pub reset: bool, // TODO?: after Some(nframes)
|
||||
/// Notes currently held at input
|
||||
pub notes_in: Arc<RwLock<[bool; 128]>>,
|
||||
/// Notes currently held at output
|
||||
pub notes_out: Arc<RwLock<[bool; 128]>>,
|
||||
}
|
||||
/// Focus layout of sequencer app
|
||||
impl<E: Engine> FocusGrid<SequencerFocus> for Sequencer<E> {
|
||||
|
|
@ -326,6 +330,9 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
Self {
|
||||
_engine: Default::default(),
|
||||
phrase: None,
|
||||
next_phrase: None,
|
||||
now: Arc::new(0.into()),
|
||||
switch_at: None,
|
||||
notes_in: Arc::new(RwLock::new([false;128])),
|
||||
notes_out: Arc::new(RwLock::new([false;128])),
|
||||
monitoring: false,
|
||||
|
|
@ -334,7 +341,6 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
midi_out: None,
|
||||
midi_out_buf: vec![Vec::with_capacity(16);16384],
|
||||
reset: true,
|
||||
now: Arc::new(0.into()),
|
||||
}
|
||||
}
|
||||
pub fn toggle_monitor (&mut self) { self.monitoring = !self.monitoring; }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ impl Phrase {
|
|||
(frame0, frames, _): (usize, usize, f64),
|
||||
) {
|
||||
let mut buf = Vec::with_capacity(8);
|
||||
for (time, tick) in Ticks(timebase.pulse_per_frame()).between_frames(
|
||||
for (time, tick) in Ticks(timebase.pulses_per_sample()).between_frames(
|
||||
frame0, frame0 + frames
|
||||
) {
|
||||
let tick = tick % self.length;
|
||||
|
|
@ -84,7 +84,7 @@ impl<E: Engine> PhrasePlayer<E> {
|
|||
}
|
||||
if self.recording {
|
||||
phrase.record_event({
|
||||
let pulse = timebase.frame_to_pulse(
|
||||
let pulse = timebase.samples_to_pulse(
|
||||
(frame0 + frame - start_frame) as f64
|
||||
);
|
||||
let quantized = (
|
||||
|
|
|
|||
|
|
@ -87,10 +87,10 @@ impl<E: Engine> TransportToolbar<E> {
|
|||
self.timebase.ppq() as usize
|
||||
}
|
||||
pub fn pulse (&self) -> usize {
|
||||
self.timebase.frame_to_pulse(self.frame as f64) as usize
|
||||
self.timebase.samples_to_pulse(self.frame as f64) as usize
|
||||
}
|
||||
pub fn usecs (&self) -> usize {
|
||||
self.timebase.frame_to_usec(self.frame as f64) as usize
|
||||
self.timebase.samples_to_usec(self.frame as f64) as usize
|
||||
}
|
||||
pub fn quant (&self) -> usize {
|
||||
self.quant
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue