pub struct MidiHost<'d, A: UsbHostAllocator<'d>> { /* private fields */ }Expand description
Friendly host driver for one USB MIDI 1.0 streaming interface.
Input-only and output-only devices are represented by an empty port slice on the unsupported direction.
It uses alternate setting 0 and sends no control request, so a device last used as MIDI 2.0
must first go through MidiInfo::deactivate.
This convenience API supports one alternate-setting-zero MIDIStreaming
interface with at most one bulk endpoint per direction. Use raw for
devices with multiple streaming interfaces or same-direction endpoints.
Implementations§
Source§impl<'d, A: UsbHostAllocator<'d>> MidiHost<'d, A>
impl<'d, A: UsbHostAllocator<'d>> MidiHost<'d, A>
Sourcepub fn new(
alloc: &A,
config_desc: &[u8],
enum_info: &EnumerationInfo,
) -> Result<Self, MidiError>
pub fn new( alloc: &A, config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>
Discover the MIDI ports and allocate the available bulk pipes.
Sourcepub fn from_info(
alloc: &A,
info: MidiInfo,
enum_info: &EnumerationInfo,
) -> Result<Self, MidiError>
pub fn from_info( alloc: &A, info: MidiInfo, enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>
Allocate the bulk pipes for a MIDI 1.0 function described by info.
Sourcepub fn input_ports(&self) -> &[MidiInputPort]
pub fn input_ports(&self) -> &[MidiInputPort]
Logical device-to-host MIDI ports.
Sourcepub fn output_ports(&self) -> &[MidiOutputPort]
pub fn output_ports(&self) -> &[MidiOutputPort]
Logical host-to-device MIDI ports.
Sourcepub async fn read_transfer(
&mut self,
buf: &mut [u8],
) -> Result<usize, MidiError>
pub async fn read_transfer( &mut self, buf: &mut [u8], ) -> Result<usize, MidiError>
Receive one bulk transfer containing USB-MIDI event packets.
Sourcepub async fn write_packet(&mut self, packets: &[u8]) -> Result<(), MidiError>
pub async fn write_packet(&mut self, packets: &[u8]) -> Result<(), MidiError>
Send one or more complete USB-MIDI event packets.
Sourcepub async fn send(
&mut self,
port: MidiOutputPort,
message: &[u8],
) -> Result<(), MidiError>
pub async fn send( &mut self, port: MidiOutputPort, message: &[u8], ) -> Result<(), MidiError>
Encode and send one MIDI message, or a SysEx fragment of up to three bytes, to a logical port.
Sourcepub async fn send_sysex(
&mut self,
port: MidiOutputPort,
message: &[u8],
) -> Result<(), MidiError>
pub async fn send_sysex( &mut self, port: MidiOutputPort, message: &[u8], ) -> Result<(), MidiError>
Sourcepub fn split(
self,
) -> (Option<MidiSender<'d, A>>, Option<MidiReceiver<'d, A>>, MidiInfo)
pub fn split( self, ) -> (Option<MidiSender<'d, A>>, Option<MidiReceiver<'d, A>>, MidiInfo)
Split into independently owned sender and receiver halves, plus the discovery info.
This allows sending and receiving from separate tasks.
Trait Implementations§
Source§impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for MidiHost<'d, A>
impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for MidiHost<'d, A>
Source§type Info = MidiInfo
type Info = MidiInfo
Source§fn probe(enum_info: &EnumerationInfo, cfg: &[u8]) -> Option<MidiInfo>
fn probe(enum_info: &EnumerationInfo, cfg: &[u8]) -> Option<MidiInfo>
None when the class is
not present. This must not allocate pipes or issue control requests. Read moreSource§async fn open(
alloc: &A,
_cfg: &[u8],
info: MidiInfo,
enum_info: &EnumerationInfo,
) -> Result<Self, ClassError>
async fn open( alloc: &A, _cfg: &[u8], info: MidiInfo, enum_info: &EnumerationInfo, ) -> Result<Self, ClassError>
Source§fn is_present(enum_info: &EnumerationInfo, cfg: &[u8]) -> bool
fn is_present(enum_info: &EnumerationInfo, cfg: &[u8]) -> bool
probe.