pub struct MidiInfo {
pub version: MidiVersion,
/* private fields */
}Expand description
The USB MIDI function of a device, as plain Copy data: version, alternate setting and endpoints.
Use discover, activate, then MidiHost::from_info or
Midi2Host::new. If activate fails with MidiError::is_midi2_failure, the device is back
on alternate setting 0: open midi1_from_config as MIDI 1.0.
Fields§
§version: MidiVersionVersion of the function.
Implementations§
Source§impl MidiInfo
impl MidiInfo
Sourcepub fn discover(
config_desc: &[u8],
enum_info: &EnumerationInfo,
) -> Result<Self, MidiError>
pub fn discover( config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>
Discover the function to use, preferring MIDI 2.0; parses descriptors only.
Sourcepub fn midi1_from_config(
config_desc: &[u8],
enum_info: &EnumerationInfo,
) -> Result<Self, MidiError>
pub fn midi1_from_config( config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>
Discover the MIDI 1.0 function: one interface on alternate setting 0, one bulk endpoint per direction.
Sourcepub fn midi2_from_config(
config_desc: &[u8],
enum_info: &EnumerationInfo,
) -> Result<Self, MidiError>
pub fn midi2_from_config( config_desc: &[u8], enum_info: &EnumerationInfo, ) -> Result<Self, MidiError>
Discover the first MIDI 2.0 function: an alternate setting reporting bcdMSC >= 0x0200,
at most one endpoint per direction.
Endpoints may be bulk or interrupt (USB MIDI 2.0 §3.3.2, §5.3). Appendix B.8 is an interrupt IN endpoint beside a bulk OUT endpoint.
Sourcepub async fn fetch_group_terminal_blocks<P>(
&self,
control_pipe: &mut P,
buffer: &mut [u8],
) -> Result<Midi2Topology, MidiError>
pub async fn fetch_group_terminal_blocks<P>( &self, control_pipe: &mut P, buffer: &mut [u8], ) -> Result<Midi2Topology, MidiError>
Fetch this MIDI 2.0 function’s Group Terminal Blocks and the groups each endpoint carries.
buffer needs GR_TRM_BLOCK_HEADER_LEN + MAX_GTBS * GR_TRM_BLOCK_LEN bytes to always fit.
Fails with MidiError::UnsupportedTopology for a MIDI 1.0 function.
Sourcepub async fn activate<P>(
&self,
control_pipe: &mut P,
) -> Result<Midi2Topology, MidiError>
pub async fn activate<P>( &self, control_pipe: &mut P, ) -> Result<Midi2Topology, MidiError>
Select a MIDI 2.0 function’s alternate setting and read its topology, before opening pipes.
On failure the device is put back on alternate setting 0. A MIDI 1.0 function needs nothing: this sends no request and returns an empty topology.
Sourcepub async fn deactivate<P>(&self, control_pipe: &mut P) -> Result<(), MidiError>
pub async fn deactivate<P>(&self, control_pipe: &mut P) -> Result<(), MidiError>
Put a MIDI 2.0 function back on alternate setting 0 before reopening it as MIDI 1.0; no request for MIDI 1.0.
Sourcepub fn interface_number(&self) -> u8
pub fn interface_number(&self) -> u8
Standard interface number of this function.
Sourcepub fn alternate_setting(&self) -> u8
pub fn alternate_setting(&self) -> u8
Alternate setting that carries this function’s protocol.
Sourcepub fn input_endpoint(&self) -> Option<&MidiEndpoint>
pub fn input_endpoint(&self) -> Option<&MidiEndpoint>
Device-to-host (IN) bulk endpoint, if the function has one.
Sourcepub fn output_endpoint(&self) -> Option<&MidiEndpoint>
pub fn output_endpoint(&self) -> Option<&MidiEndpoint>
Host-to-device (OUT) bulk endpoint, if the function has one.