MCPcopy Index your code
hub / github.com/chris-zen/coremidi

github.com/chris-zen/coremidi @0.9.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.9.1 ↗ · + Follow
294 symbols 570 edges 23 files 112 documented · 38%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

coremidi

CI Crates.io Crates.io docs.rs Minimum rustc version

This is a CoreMIDI library for Rust built on top of the low-level bindings coremidi-sys. CoreMIDI is a macOS framework that provides APIs for communicating with MIDI (Musical Instrument Digital Interface) devices, including hardware keyboards and synthesizers.

This library preserves the fundamental concepts behind the CoreMIDI framework, while being Rust idiomatic. This means that if you already know CoreMIDI, you will find very easy to start using it.

Please see the examples for an idea on how to use it, but if you are eager to see some code, this is how you would send some note:

use coremidi::{Client, Destination, EventBuffer, Protocol};
use std::time::Duration;
use std::thread;

fn main() {
  let client = Client::new("example-client").unwrap();
  let output_port = client.output_port("example-port").unwrap();
  let destination = Destination::from_index(0).unwrap();
  let chord_on = EventBuffer::new(Protocol::Midi10)
    .with_packet(0, &[0x2090407f])
    .with_packet(0, &[0x2090447f]);
  let chord_off = EventBuffer::new(Protocol::Midi10)
    .with_packet(0, &[0x2080407f])
    .with_packet(0, &[0x2080447f]);
  output_port.send(&destination, &chord_on).unwrap();
  thread::sleep(Duration::from_millis(1000));
  output_port.send(&destination, &chord_off).unwrap();
}

If you are looking for a portable MIDI library then you can look into: - midir (which is using this lib) - portmidi-rs

For handling low level MIDI data you may look into: - rimd - midi-rs

Installation

Add the following to your Cargo.toml:

[dependencies]
coremidi = "0.9.0"

To play with the source code yourself you can clone the repo and build the code and documentation with the following commands:

git clone https://github.com/chris-zen/coremidi.git
cd coremidi
cargo build
cargo test
cargo doc --open

Examples

The examples can be run with:

cargo run --example send

These are the provided examples:

  • endpoints: how to enumerate sources and destinations.
  • send: how to create an output port and send MIDI messages.
  • receive: how to create an input port and receive MIDI messages.
  • virtual-source: how to create a virtual source and generate MIDI messages.
  • virtual-destination: how to create a virtual destination and receive MIDI messages.
  • properties: how to set and get properties on MIDI objects.
  • notifications: how to receive MIDI client notifications.

Extension points exported contracts — how you extend this code

PropertyGetter (Interface)
(no doc) [3 implementers]
src/properties.rs
PropertySetter (Interface)
(no doc) [3 implementers]
src/properties.rs

Core symbols most depended-on inside this repo

as_ptr
called by 13
src/events.rs
with_packet
called by 13
src/events.rs
result_from_status
called by 13
src/lib.rs
value_from
called by 13
src/properties.rs
as_mut_ptr
called by 12
src/events.rs
push_data
called by 12
src/packets.rs
iter
called by 11
src/packets.rs
len
called by 10
src/events.rs

Shape

Method 170
Function 83
Class 32
Enum 7
Interface 2

Languages

Rust100%

Modules by API surface

src/properties.rs63 symbols
src/packets.rs46 symbols
src/events.rs43 symbols
src/notifications.rs18 symbols
src/endpoints/sources.rs18 symbols
src/client.rs17 symbols
src/endpoints/destinations.rs14 symbols
src/object.rs13 symbols
src/ports.rs12 symbols
src/protocol.rs10 symbols
src/any_object.rs6 symbols
src/entity.rs5 symbols

For agents

$ claude mcp add coremidi \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page