Skip to main content

Context

Struct Context 

Source
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

Source

pub fn set_bpm(&mut self, bpm: u8)

Sets the BPM (Beats per minute) of the sequencer.

Source

pub fn get_bpm(&self) -> u8

Gets the current BPM of the sequencer.

Source

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.

Source

pub fn quit(&mut self)

Stops and exit the sequencer.

Source

pub fn pause(&mut self)

Pauses the sequencer and send a MIDI stop message.

Source

pub fn resume(&mut self)

Resumes the sequencer and send a MIDI continue message.

Source

pub fn start(&mut self)

Starts the sequencer and send a MIDI start message. The current step is set to 0.

Source

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
Source

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.

Source

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.

Source

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.

Source

pub fn is_running(&self) -> bool

Returns true if the sequencer is currently running, false otherwise.

Source

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.

Trait Implementations§

Source§

impl Default for Context

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.