Skip to content

Commit 69598e5

Browse files
committed
Update documentation
1 parent 0b1f98b commit 69598e5

File tree

3 files changed

+89
-10
lines changed

3 files changed

+89
-10
lines changed

midi_io/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.7
2+
3+
- Update Readme, no functional changes
4+
15
## 1.0.6
26

37
- Update link to Git repo

midi_io/README.md

Lines changed: 84 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,90 @@
1-
# midi_io
1+
# Midi IO
22

3-
A new flutter plugin project.
3+
Send and receive Midi Messages on Android, iOS, and MacOS!
4+
5+
This plugin provides flutter bindings to interact with MIDI devices.
6+
The API design is draws heavily from the [Web MIDI](https://www.w3.org/TR/webmidi/) spec, providing a common API
7+
that wraps [Core Midi](https://developer.apple.com/documentation/coremidi/) on iOS and MacOS,
8+
and [androidx.media.midi](https://developer.android.com/reference/android/media/midi/package-summary) on Android.
9+
10+
## Terminology
11+
12+
In order to provide a unified, platform agnostic Flutter API, the plugin uses the following terms:
13+
14+
- **Device** A device is Midi hardware or software that provides one or more Midi input and output ports. This plugin abstracts Devices away from you and simply provides a unified list of source and destination ports you can read from and write to. If you are coming from Web MIDI or Core MIDI this is regular practice, but Android has the Device abstraction, so this way of working may be new.
15+
16+
- **Source** A Source is a port your app can listen to midi messages _from_. This is equivalent to a `MIDIInput` in WebMIDI.
17+
18+
- **Destination** A Destination is a port your app can send messages _to_. This is equivalent to a `MIDIOutput` in WebMIDI.
419

520
## Getting Started
621

7-
This project is a starting point for a Flutter
8-
[plug-in package](https://flutter.dev/developing-packages/),
9-
a specialized package that includes platform-specific implementation code for
10-
Android and/or iOS.
22+
The `Midi` class is the main entry point into the MIDI system.
23+
24+
```dart
25+
final midi = Midi():
26+
```
27+
28+
## Listing Connected Ports
29+
30+
You can get the list of connected sources and destinations like so:
31+
32+
```dart
33+
final midi = Midi();
34+
35+
final List<MidiSourcePort> sources = await midi.getSources();
36+
final List<MidiDestinationPort> destinations = await midi.getDestinations();
37+
```
38+
39+
In addition, you can also listen to a stream of connection events that occur when devices are plugged in and unplugged:
40+
41+
```dart
42+
await for (ConnectionEvent event in midi.onDevicesChanged) {
43+
// process event
44+
}
45+
```
46+
47+
Use cases for the `onDevicesChanged` stream include automatically connecting to a particular device, etc.
48+
49+
## Sending Messages
50+
51+
To send midi messages to an DestinationPort, first open it, then use the send method:
52+
53+
```dart
54+
final List<MidiDestinationPort> destinations = await midi.getDestinations();
55+
final myDestination = destinations.first;
56+
await myDestination.open();
57+
58+
// Key down on middle C
59+
await myDestination.send([0x90, 0x3C, 0x40]);
60+
```
61+
62+
## Listening to Messages
63+
64+
Listening to messages from a Midi Source requires opening and subscribing to the `messages` Stream:
65+
66+
```dart
67+
final List<MidiSourcePort> sources = await midi.getSources();
68+
final mySource = sources.first;
69+
await mySource.open();
70+
71+
await for (let message of mySource.messages) {
72+
// process Midi message here
73+
}
74+
```
75+
76+
### Filtering
77+
78+
Since messages are sent as a Stream, you can filter midi messages using standard Dart techniques.
79+
80+
For example, we provide a built in filter to hide MIDI clock messages:
81+
82+
```dart
83+
await for (let message of mySource.messages.where(excludeClock)) {
84+
// process Midi message here
85+
}
86+
```
1187

12-
For help getting started with Flutter, view our
13-
[online documentation](https://flutter.dev/docs), which offers tutorials,
14-
samples, guidance on mobile development, and a full API reference.
88+
## Contributing
1589

90+
This plugin is a work in progress, and due to the scope of how MIDI can be used, and different platform specifics, There's plenty of room to help. Bug reports and Pull Requests are welcome!

midi_io/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: midi_io
22
description: A new flutter plugin project.
3-
version: 1.0.6
3+
version: 1.0.7
44
homepage: https://patchr.app
55
repository: https://github.com/patchr-app/flutter_midi
66

0 commit comments

Comments
 (0)