Skip to main content

MidiSender

Struct MidiSender 

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

One render thread’s end of the output queue.

Held in that thread’s RenderState, taken from MidiOutput::take_sender. Not Clone: one sender is one writer, and that is what the queue behind it relies on.

Implementations§

Source§

impl MidiSender

Source

pub fn send( &mut self, context: &impl CallbackContext, message: MidiMessage, ) -> Result<(), Error>

Queues message and asks for the queue to be emptied.

Real-time safe, and the whole of what render does: one store into a ring, one index update, and a schedule — the same one AuxiliaryTask::schedule documents. Bela’s pipe is written on the task’s thread, not here.

Not the same call as MidiOutput::send, which shares its name and little else: that one writes to Bela’s pipe itself and waits for the drain, and belongs in setup or cleanup. This one is the one a render callback may make.

The context is the callback this is being sent from, as AuxiliaryTask::schedule requires.

§When it leaves

With the next drain, which the schedule here asks for. A request that arrives while the drain is running is dropped rather than queued — that is AuxiliaryTask::schedule’s documented behaviour — so the drain looks again before it finishes, and only stops when the queues are empty.

What is left is the few instructions between that last look and the callback returning. A message queued there waits for the next send to schedule a drain. A program that sends continuously never notices; one that sends a note off and then nothing can, which is the case to know about.

§Errors

Error::MidiQueueFull when this thread has already queued MidiOutput::capacity messages that have not been drained. The message is not queued, and nothing later is affected: the next drain empties what is there and the next send succeeds. It says the program outran the budget it declared, and nothing about the device — see MidiOutput.

Source

pub const fn thread(&self) -> usize

Which render thread this sender belongs to.

Trait Implementations§

Source§

impl Debug for MidiSender

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.