Debian Codegraph @

third_party/rust/coremidi/README.md

raw
1 # coremidi
2
3 This is a [CoreMIDI](https://developer.apple.com/reference/coremidi) library for Rust built on top of the low-level bindings [coremidi-sys](https://github.com/jonas-k/coremidi-sys).
4 CoreMIDI is a macOS framework that provides APIs for communicating with MIDI (Musical Instrument Digital Interface) devices, including hardware keyboards and synthesizers.
5
6 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.
7
8 The **documentation** for the master branch can be found here: https://chris-zen.github.io/coremidi/coremidi/
9
10 Please see the [examples](examples) for an idea on how it looks like, but if you are eager to see some code, this is how you would send some note:
11
12 ```rust
13 extern crate coremidi;
14 use coremidi::{Client, Destinations, PacketBuffer};
15 use std::time::Duration;
16 use std::thread;
17 let client = Client::new("example-client").unwrap();
18 let output_port = client.output_port("example-port").unwrap();
19 let destination = Destinations::from_index(0).unwrap();
20 let note_on = PacketBuffer::new(0, &[0x90, 0x40, 0x7f]);
21 let note_off = PacketBuffer::new(0, &[0x80, 0x40, 0x7f]);
22 output_port.send(&destination, &note_on).unwrap();
23 thread::sleep(Duration::from_millis(1000));
24 output_port.send(&destination, &note_off).unwrap();
25 ```
26
27 If you are looking for a portable MIDI library then you can look into:
28 - [midir](https://github.com/Boddlnagg/midir) (which is using this lib)
29 - [portmidi-rs](https://github.com/musitdev/portmidi-rs)
30
31 For handling low level MIDI data you may look into:
32 - [rimd](https://github.com/RustAudio/rimd)
33 - [midi-rs](https://github.com/samdoshi/midi-rs)
34
35 [![Build Status](https://travis-ci.org/chris-zen/coremidi.svg?branch=master)](https://travis-ci.org/chris-zen/coremidi)
36 [![Crates.io](https://img.shields.io/crates/v/coremidi.svg)](https://crates.io/crates/coremidi)
37 [![Crates.io](https://img.shields.io/crates/d/coremidi.svg)](https://crates.io/crates/coremidi)
38 [![Crates.io](https://img.shields.io/crates/dv/coremidi.svg)](https://crates.io/crates/coremidi)
39 [![GitHub tag](https://img.shields.io/github/tag/chris-zen/coremidi.svg)](https://travis-ci.org/chris-zen/coremidi)
40 [![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-blue.svg)](https://blog.rust-lang.org/2019/07/04/Rust-1.36.0.html)
41 [![Join the chat at https://gitter.im/coremidi/Lobby](https://badges.gitter.im/coremidi/Lobby.svg)](https://gitter.im/coremidi/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
42
43 # Installation
44
45 The library is published into [crates.io](https://crates.io/crates/coremidi), so it can be used by adding the following lines into your `Cargo.toml` file (but remember to update the version number accordingly):
46
47 ```toml
48 [dependencies]
49 coremidi = "^0.6.0"
50 ```
51
52 If you prefer to live in the edge ;-) you can use the master branch by including this instead:
53
54 ```toml
55 [dependencies]
56 coremidi = { git = "https://github.com/chris-zen/coremidi", branch="master" }
57 ```
58
59 To play with the source code yourself you can clone the repo and build the code and documentation with the following commands:
60
61 ```sh
62 git clone https://github.com/chris-zen/coremidi.git
63 cd coremidi
64 cargo build
65 cargo test
66 cargo doc
67 open target/doc/coremidi/index.html
68 ```
69
70 # Examples
71
72 The examples can be run with:
73
74 ```sh
75 cargo run --example send
76 ```
77
78 These are the provided examples:
79
80 - [endpoints](examples/endpoints.rs): how to enumerate sources and destinations.
81 - [send](examples/send.rs): how to create an output port and send MIDI messages.
82 - [receive](examples/receive.rs): how to create an input port and receive MIDI messages.
83 - [virtual-source](examples/virtual-source.rs): how to create a virtual source and generate MIDI messages.
84 - [virtual-destination](examples/virtual-destination.rs): how to create a virtual destination and receive MIDI messages.
85 - [properties](examples/properties.rs): how to set and get properties on MIDI objects.
86 - [notifications](examples/notifications.rs): how to receive MIDI client notifications.
87
88 # Roadmap
89
90 - [x] Enumerate destinations
91 - [x] Create output ports
92 - [x] Create a PacketList from MIDI bytes
93 - [x] Send a PacketList into an output port
94 - [x] Create virtual sources
95 - [x] Support a virtual source receiving a PacketList
96 - [x] Flush output
97 - [x] Enumerate sources
98 - [x] Create input ports
99 - [x] Support callbacks from input messages
100 - [x] Connect and disconnect sources
101 - [x] Add support to build PacketList (PacketBuffer)
102 - [x] Create virtual destinations with callback
103 - [x] Stop and restart MIDI I/O
104 - [x] MIDI Objects and properties
105 - [x] Client notifications
106 - [ ] Support Sysex
107 - [ ] Support devices
108 - [ ] Support entities
109 - [ ] MIDIThru connections