Skip to main content

MidiToSoundBridge

Struct MidiToSoundBridge 

Source
pub struct MidiToSoundBridge { /* private fields */ }
Expand description

A MidiSink that interprets MIDI events into scheduled tones, managing per-channel state, tuning, voice allocation, and timing.

Implementations§

Source§

impl MidiToSoundBridge

Source

pub fn new( tpq: u32, bank: TimbreBank, tuning: Box<dyn Tuning>, options: BridgeOptions, ) -> Result<Self, SoundBridgeError>

Builds a bridge with the given ticks-per-quarter, timbre bank, tuning, and options.

Source

pub fn options(&self) -> &BridgeOptions

Returns the bridge options.

Source

pub fn bank(&self) -> &TimbreBank

Returns the timbre bank.

Source

pub fn voice_pool(&self) -> &VoicePool

Returns the underlying voice pool.

Source

pub fn drain_tones(&mut self) -> Vec<ScheduledTone>

Drains all tones emitted so far, returning them and clearing the buffer.

Source

pub fn stolen_voice_count(&self) -> usize

Returns the number of voices stolen due to polyphony limits.

Trait Implementations§

Source§

impl MidiSink for MidiToSoundBridge

Source§

type Err = SoundBridgeError

Error type returned by write and flush.
Source§

fn tpq(&self) -> u32

Returns the sink resolution in ticks per quarter note.
Source§

fn write(&mut self, event: &MidiEvent) -> Result<(), Self::Err>

Writes one event to the sink.
Source§

fn flush(&mut self) -> Result<(), Self::Err>

Flushes any buffered state to the underlying destination.

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.