/// A [MIDI source](https://developer.apple.com/documentation/coremidi/midiendpointref) owned by an entity. /// /// A source can be created from an index like this: /// /// ```rust,no_run /// let source = coremidi::Source::from_index(0).unwrap(); /// println!("The source at index 0 has display name '{}'", source.display_name().unwrap()); /// ``` /// #[derive(Debug, Hash, Eq, PartialEq)] pubstruct Source { pub(crate) endpoint: Endpoint,
}
/// Source endpoints available in the system. /// /// The number of sources available in the system can be retrieved with: /// /// ```rust,no_run /// let number_of_sources = coremidi::Sources::count(); /// ``` /// /// The sources in the system can be iterated as: /// /// ```rust,no_run /// for source in coremidi::Sources { /// println!("{}", source.display_name().unwrap()); /// } /// ``` /// pubstruct Sources;
/// A [MIDI virtual source](https://developer.apple.com/documentation/coremidi/1495212-midisourcecreate) owned by a client. /// /// A virtual source can be created like: /// /// ```rust,no_run /// let client = coremidi::Client::new("example-client").unwrap(); /// let source = client.virtual_source("example-source").unwrap(); /// ``` /// #[derive(Debug, Hash, Eq, PartialEq)] pubstruct VirtualSource { pub(crate) endpoint: Endpoint,
}
/// Distributes incoming MIDI from a source to the client input ports which are connected to that source. /// See [MIDIReceived](https://developer.apple.com/documentation/coremidi/1495276-midireceived) /// pubfn received<'a, P>(&self, packets: P) -> Result<(), OSStatus> where
P: Into<Packets<'a>>,
{ let status = match packets.into() {
Packets::BorrowedPacketList(packet_list) => unsafe {
MIDIReceived(self.endpoint.object.0, packet_list.as_ptr())
},
Packets::BorrowedEventList(event_list) => unsafe {
MIDIReceivedEventList(self.endpoint.object.0, event_list.as_ptr())
},
Packets::OwnedEventBuffer(event_buffer) => unsafe {
MIDIReceivedEventList(self.endpoint.object.0, event_buffer.as_ptr())
},
};
if status == 0 {
Ok(())
} else {
Err(status)
}
}
}
impl Deref for VirtualSource { type Target = Endpoint;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.