pub trait Synth {
// Required methods
fn current_time(&self) -> u32;
fn play_msg_at(&mut self, msg: u32, time: u32) -> bool;
fn play_sysex_at(&mut self, sysex: &[u8], time: u32) -> bool;
fn render(&mut self, out: &mut [Frame]);
// Provided methods
fn play_msg(&mut self, msg: u32) -> bool { ... }
fn play_sysex(&mut self, sysex: &[u8]) -> bool { ... }
}Expand description
Interface for MIDI synthesizers.
MIDI messages must be added in time-ascending order, otherwise they will be ignored during rendering.
Required Methods§
Sourcefn current_time(&self) -> u32
fn current_time(&self) -> u32
Returns the number of frames rendered so far.
Sourcefn play_msg_at(&mut self, msg: u32, time: u32) -> bool
fn play_msg_at(&mut self, msg: u32, time: u32) -> bool
Enqueues one MIDI message at a specific frame.
A MIDI baud rate transfer delay is added to time before
enqueuing: 24 frames for 3-byte messages, 16 frames for
2-byte messages (program change and channel pressure).
Sourcefn play_sysex_at(&mut self, sysex: &[u8], time: u32) -> bool
fn play_sysex_at(&mut self, sysex: &[u8], time: u32) -> bool
Enqueues one MIDI System Exclusive message at a specific frame.
No transfer delay is added; the message is processed at exactly the given frame.
Provided Methods§
Sourcefn play_msg(&mut self, msg: u32) -> bool
fn play_msg(&mut self, msg: u32) -> bool
Enqueues one MIDI message starting from the current frame.
Equivalent to play_msg_at(msg, current_time()). The message
is processed after the MIDI baud rate transfer delay (16 or
24 frames), not at the current frame itself.
Sourcefn play_sysex(&mut self, sysex: &[u8]) -> bool
fn play_sysex(&mut self, sysex: &[u8]) -> bool
Enqueues one MIDI System Exclusive message at the current frame.
Equivalent to play_sysex_at(sysex, current_time()). The
message is processed immediately at the current frame.