mod input;
mod output;
mod port;
#[cfg(target_os = "macos")]
mod coremidi_impl;
#[cfg(target_os = "linux")]
mod alsa_impl;
#[cfg(target_os = "windows")]
mod winmm_impl;
pub use input::MidiInput;
pub use output::MidiOutput;
pub use port::{Api, MidiPort};
use thiserror::Error;
pub fn get_version() -> &'static str {
env!("CARGO_PKG_VERSION")
}
#[derive(Debug, Error)]
pub enum RtMidiError {
#[error("no MIDI ports available")]
NoPortsAvailable,
#[error("invalid port number: {0}")]
InvalidPort(usize),
#[error("port already open")]
PortAlreadyOpen,
#[error("port not open")]
PortNotOpen,
#[error("failed to create virtual port")]
VirtualPortError,
#[error("system error: {0}")]
SystemError(String),
#[error("driver error: {0}")]
DriverError(String),
#[error("invalid message")]
InvalidMessage,
#[error("thread error: {0}")]
ThreadError(String),
#[error("warning: {0}")]
Warning(String),
#[error("debug warning: {0}")]
DebugWarning(String),
}
pub type MidiCallback = Box<dyn FnMut(f64, &[u8]) + Send>;
pub type RtMidiErrorCallback = Box<dyn FnMut(&RtMidiError) + Send>;
#[derive(Debug, Clone)]
pub struct MidiInputConfig {
pub queue_size: usize,
pub ignore_timing: bool,
pub ignore_active_sensing: bool,
pub ignore_sysex: bool,
}
impl Default for MidiInputConfig {
fn default() -> Self {
Self {
queue_size: 100,
ignore_timing: true,
ignore_active_sensing: true,
ignore_sysex: true,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_version_matches_cargo_pkg_version() {
assert_eq!(get_version(), env!("CARGO_PKG_VERSION"));
}
}