tek/engine/engine_structs.rs
stop screaming 37068784cb refactor(engine): flatten
- add `just stats`
- add basic doctests
2026-02-21 00:03:06 +02:00

156 lines
3.3 KiB
Rust

use crate::*;
/// Temporal resolutions: sample rate, tempo, MIDI pulses per quaver (beat)
///
/// ```
///
/// ```
#[derive(Debug, Clone)] pub struct Timebase {
/// Audio samples per second
pub sr: SampleRate,
/// MIDI beats per minute
pub bpm: BeatsPerMinute,
/// MIDI ticks per beat
pub ppq: PulsesPerQuaver,
}
/// Iterator that emits subsequent ticks within a range.
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct TicksIterator {
pub spp: f64,
pub sample: usize,
pub start: usize,
pub end: usize,
}
///
/// ```
/// let model = MidiSelection::from((1, false));
///
/// let _ = model.get_time_len();
/// let _ = model.get_time_zoom();
/// let _ = model.get_time_lock();
/// let _ = model.get_time_start();
/// let _ = model.get_time_axis();
/// let _ = model.get_time_end();
///
/// let _ = model.get_note_lo();
/// let _ = model.get_note_axis();
/// let _ = model.get_note_hi();
/// ```
#[derive(Debug, Clone)] pub struct MidiCursor {
/// Time coordinate of cursor
pub time_pos: Arc<AtomicUsize>,
/// Note coordinate of cursor
pub note_pos: Arc<AtomicUsize>,
/// Length of note that will be inserted, in pulses
pub note_len: Arc<AtomicUsize>,
}
///
/// ```
///
/// ```
#[derive(Debug, Clone, Default)] pub struct MidiSelection {
pub time_len: Arc<AtomicUsize>,
/// Length of visible time axis
pub time_axis: Arc<AtomicUsize>,
/// Earliest time displayed
pub time_start: Arc<AtomicUsize>,
/// Time step
pub time_zoom: Arc<AtomicUsize>,
/// Auto rezoom to fit in time axis
pub time_lock: Arc<AtomicBool>,
/// Length of visible note axis
pub note_axis: Arc<AtomicUsize>,
// Lowest note displayed
pub note_lo: Arc<AtomicUsize>,
}
/// A point in time in all time scales (microsecond, sample, MIDI pulse)
///
/// ```
///
/// ```
#[derive(Debug, Default, Clone)]
pub struct Moment {
pub timebase: Arc<Timebase>,
/// Current time in microseconds
pub usec: Microsecond,
/// Current time in audio samples
pub sample: SampleCount,
/// Current time in MIDI pulses
pub pulse: Pulse,
}
///
/// ```
///
/// ```
#[derive(Debug, Clone, Default)]
pub enum Moment2 {
#[default] None,
Zero,
Usec(Microsecond),
Sample(SampleCount),
Pulse(Pulse),
}
/// MIDI resolution in PPQ (pulses per quarter note)
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct PulsesPerQuaver (pub(crate) AtomicF64);
/// Timestamp in MIDI pulses
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct Pulse (pub(crate) AtomicF64);
/// Tempo in beats per minute
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct BeatsPerMinute (pub(crate) AtomicF64);
/// Quantization setting for launching clips
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct LaunchSync (pub(crate) AtomicF64);
/// Quantization setting for notes
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct Quantize (pub(crate) AtomicF64);
/// Timestamp in audio samples
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct SampleCount (pub(crate) AtomicF64);
/// Audio sample rate in Hz (samples per second)
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct SampleRate (pub(crate) AtomicF64);
/// Timestamp in microseconds
///
/// ```
///
/// ```
#[derive(Debug, Default)] pub struct Microsecond (pub(crate) AtomicF64);