Struct MidiFileSequencer

Source
#[non_exhaustive]
pub struct MidiFileSequencer { /* private fields */ }
Expand description

An instance of the MIDI file sequencer.

Implementations§

Source§

impl MidiFileSequencer

Source

pub fn new(synthesizer: Synthesizer) -> Self

Initializes a new instance of the sequencer.

§Arguments
  • synthesizer - The synthesizer to be handled by the sequencer.
Source

pub fn play(&mut self, midi_file: &Arc<MidiFile>, play_loop: bool)

Plays the MIDI file.

§Arguments
  • midi_file - The MIDI file to be played.
  • play_loop - If true, the MIDI file loops after reaching the end.
Source

pub fn stop(&mut self)

Stops playing.

Source

pub fn render(&mut self, left: &mut [f32], right: &mut [f32])

Renders the waveform.

§Arguments
  • left - The buffer of the left channel to store the rendered waveform.
  • right - The buffer of the right channel to store the rendered waveform.
§Remarks

The output buffers for the left and right must be the same length.

Source

pub fn get_synthesizer(&self) -> &Synthesizer

Gets the synthesizer handled by the sequencer.

Source

pub fn get_midi_file(&self) -> Option<&MidiFile>

Gets the currently playing MIDI file.

Source

pub fn get_position(&self) -> f64

Gets the current playback position in seconds.

Source

pub fn end_of_sequence(&self) -> bool

Gets a value that indicates whether the current playback position is at the end of the sequence.

§Remarks

If the play method has not yet been called, this value will be true. This value will never be true if loop playback is enabled.

Source

pub fn get_speed(&self) -> f64

Gets the current playback speed.

§Remarks

The default value is 1. The tempo will be multiplied by this value during playback.

Source

pub fn set_speed(&mut self, value: f64)

Sets the playback speed.

§Remarks

The value must be non-negative.

Trait Implementations§

Source§

impl Debug for MidiFileSequencer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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.