Struct portmidi::PortMidi

source ·
pub struct PortMidi { /* private fields */ }
Expand description

The PortMidi base struct. Initializes PortMidi on creation and terminates it on drop.

Implementations§

source§

impl PortMidi

source

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.

source

pub fn device_count(&self) -> PortMidiDeviceId

Return the number of devices. This number will not change during the lifetime of the program.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl Drop for PortMidi

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.