pub struct Context { /* private fields */ }Expand description
An object of type Context is passed to the user’s Conductor at each clock tick
via the Conductor::update method. It provides a high-level interface to send
system MIDI messages and modify system parameters.
The user can set MIDI system parameters (e.g., Context::set_bpm) or send system messages
(e.g., Context::start) using the provided methods.
In addition to sending the corresponding MIDI system messages, these methods also update the internal logic of the sequencer to reflect the change.
Implementations§
Source§impl Context
impl Context
Sourcepub fn get_period_us(&self) -> u64
pub fn get_period_us(&self) -> u64
Gets the current period (in microsec) of the sequencer. A period represents the amount of time between each MIDI clock messages.
Sourcepub fn start(&mut self)
pub fn start(&mut self)
Starts the sequencer and send a MIDI start message. The current step is set to 0.
Sourcepub fn get_step(&self) -> u32
pub fn get_step(&self) -> u32
Retrieves the current MIDI step.
- 96 steps make a bar
- 24 steps make a whole note
- 12 steps make a half note
- 6 steps make a quarter note
Sourcepub fn init(
&mut self,
conductor: &mut impl Conductor,
controller: &mut MidiController<impl MidiOut>,
)
pub fn init( &mut self, conductor: &mut impl Conductor, controller: &mut MidiController<impl MidiOut>, )
MIDI logic called at the initialization.
This function is not intended to be called directly by users.
init is used internally to enable code reuse across platforms.
Sourcepub fn process_pre_tick(
&mut self,
conductor: &mut impl Conductor,
controller: &mut MidiController<impl MidiOut>,
)
pub fn process_pre_tick( &mut self, conductor: &mut impl Conductor, controller: &mut MidiController<impl MidiOut>, )
MIDI logic called before the clock tick.
This function is not intended to be called directly by users.
process_pre_tick is used internally to enable code reuse across platforms.
Sourcepub fn process_post_tick(
&mut self,
controller: &mut MidiController<impl MidiOut>,
)
pub fn process_post_tick( &mut self, controller: &mut MidiController<impl MidiOut>, )
MIDI logic called after the clock tick.
This function is not intended to be called directly by users.
process_post_tick is used internally to enable code reuse across platforms.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true if the sequencer is currently running, false otherwise.
Sourcepub fn handle_input(
&mut self,
conductor: &mut impl Conductor,
controller: &mut MidiController<impl MidiOut>,
input_queue: &mut InputQueue,
)
pub fn handle_input( &mut self, conductor: &mut impl Conductor, controller: &mut MidiController<impl MidiOut>, input_queue: &mut InputQueue, )
Internal MIDI input handler.
This function is not intended to be called directly by users.
Instead, users should implement Conductor::handle_input for their custom input handler logic.
handle_input is used internally to enable code reuse across platforms and unify MIDI input processing.