pub struct PortMidi { /* private fields */ }
Expand description
The PortMidi base struct. Initializes PortMidi on creation and terminates it on drop.
Implementations§
source§impl PortMidi
impl PortMidi
sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Initializes the underlying PortMidi C library.
PortMidi does not support hot plugging, this means
that devices that are connect after calling new
are not picked up.
sourcepub fn device_count(&self) -> PortMidiDeviceId
pub fn device_count(&self) -> PortMidiDeviceId
Return the number of devices. This number will not change during the lifetime of the program.
sourcepub fn default_input_device_id(&self) -> Result<PortMidiDeviceId>
pub fn default_input_device_id(&self) -> Result<PortMidiDeviceId>
Returns the PortMidiDeviceId
for the default input device, or an Error::NoDefaultDevice
if
there is no available.
sourcepub fn default_output_device_id(&self) -> Result<PortMidiDeviceId>
pub fn default_output_device_id(&self) -> Result<PortMidiDeviceId>
Returns the PortMidiDeviceId
for the default output device, or an Error::NoDefaultDevice
if
there is no available.
sourcepub fn device(&self, id: PortMidiDeviceId) -> Result<DeviceInfo>
pub fn device(&self, id: PortMidiDeviceId) -> Result<DeviceInfo>
Returns the DeviceInfo
for the given device id or an Error::PortMidi(_)
if
the given id is invalid.
sourcepub fn devices(&self) -> Result<Vec<DeviceInfo>>
pub fn devices(&self) -> Result<Vec<DeviceInfo>>
Returns a Vec<DeviceInfo>
containing all known device infos.
An Error::PortMidi(_)
is returned if the info for a device can’t be obtained.
sourcepub fn default_input_port(&self, buffer_size: usize) -> Result<InputPort<'_>>
pub fn default_input_port(&self, buffer_size: usize) -> Result<InputPort<'_>>
Creates an InputPort
instance with the given buffer size for the default input device.
sourcepub fn input_port(
&self,
device: DeviceInfo,
buffer_size: usize
) -> Result<InputPort<'_>>
pub fn input_port( &self, device: DeviceInfo, buffer_size: usize ) -> Result<InputPort<'_>>
Creates an InputPort
instance for the given device and buffer size.
If the given device is not an input device an Error::NotAnInputDevice
is returned.
sourcepub fn default_output_port(&self, buffer_size: usize) -> Result<OutputPort<'_>>
pub fn default_output_port(&self, buffer_size: usize) -> Result<OutputPort<'_>>
Creates an OutputPort
instance with the given buffer size for the default output device.
sourcepub fn output_port(
&self,
device: DeviceInfo,
buffer_size: usize
) -> Result<OutputPort<'_>>
pub fn output_port( &self, device: DeviceInfo, buffer_size: usize ) -> Result<OutputPort<'_>>
Creates an OutputPort
instance for the given device and buffer size.
If the given device is not an output device an Error::NotAnOutputDevice
is returned.
sourcepub fn create_virtual_input(&self, name: &str) -> Result<VirtualDevice>
pub fn create_virtual_input(&self, name: &str) -> Result<VirtualDevice>
Creates a virtual output device for the lifetime of the PortMidi instance. Returns the device info of the created device or throws an Error.
sourcepub fn create_virtual_output(&self, name: &str) -> Result<VirtualDevice>
pub fn create_virtual_output(&self, name: &str) -> Result<VirtualDevice>
Creates a virtual input device for the lifetime of the PortMidi instance. Returns the device info of the created device or throws an Error.