pub struct MidiInput { /* private fields */ }
Expand description
An instance of MidiInput
is required for anything related to MIDI input.
Create one with MidiInput::new
.
Implementations§
source§impl MidiInput
impl MidiInput
sourcepub fn new(client_name: &str) -> Result<Self, InitError>
pub fn new(client_name: &str) -> Result<Self, InitError>
Creates a new MidiInput
object that is required for any MIDI input functionality.
sourcepub fn ignore(&mut self, flags: Ignore)
pub fn ignore(&mut self, flags: Ignore)
Set flags to decide what kind of messages should be ignored (i.e., filtered out)
by this MidiInput
. By default, no messages are ignored.
sourcepub fn ports(&self) -> MidiInputPorts
pub fn ports(&self) -> MidiInputPorts
Get a collection of all MIDI input ports that midir can connect to. The resulting vector contains one object per port, which you can use to query metadata about the port or connect to it in order to receive MIDI messages.
sourcepub fn port_count(&self) -> usize
pub fn port_count(&self) -> usize
Get the number of available MIDI input ports that midir can connect to.
sourcepub fn port_name(&self, port: &MidiInputPort) -> Result<String, PortInfoError>
pub fn port_name(&self, port: &MidiInputPort) -> Result<String, PortInfoError>
Get the name of a specified MIDI input port.
An error will be returned when the port is no longer valid (e.g. the respective device has been disconnected).
sourcepub fn connect<F, T: Send>(
self,
port: &MidiInputPort,
port_name: &str,
callback: F,
data: T
) -> Result<MidiInputConnection<T>, ConnectError<MidiInput>>
pub fn connect<F, T: Send>( self, port: &MidiInputPort, port_name: &str, callback: F, data: T ) -> Result<MidiInputConnection<T>, ConnectError<MidiInput>>
Connect to a specified MIDI input port in order to receive messages.
For each incoming MIDI message, the provided callback
function will
be called. The first parameter of the callback function is a timestamp
(in microseconds) designating the time since some unspecified point in
the past (which will not change during the lifetime of a
MidiInputConnection
). The second parameter contains the actual bytes
of the MIDI message.
Additional data that should be passed whenever the callback is
invoked can be specified by data
. Use the empty tuple ()
if
you do not want to pass any additional data.
The connection will be kept open as long as the returned
MidiInputConnection
is kept alive.
The port_name
is an additional name that will be assigned to the
connection. It is only used by some backends.
An error will be returned when the port is no longer valid (e.g. the respective device has been disconnected).