Skip to content

Commit 695e707

Browse files
author
Ben Leadbetter
committed
docs: change working in root README
1 parent 01541e4 commit 695e707

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Ergonomic, versatile, strong types wrapping MIDI 2.0 message data.
44

55
This implementation of MIDI 2.0 is based on the 1.1 revision of the specifications.
6-
For detailed midi2 specification see [the documentation](https://midi.org/)
7-
on which this crate is based.
6+
See [the official MIDI 2.0 specification](https://midi.org/)
7+
for more details on the data protocol standard.
88

99
## ⚠️ **Note!** ⚠️
1010

src/channel_voice1/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ message.set_control(u7::new(0x36));
1515
message.set_control_data(u7::new(0x37));
1616

1717
assert_eq!(message.data(), &[0x2CBA_3637]);
18+
assert_eq!(message.channel(), u4::new(0xA));
19+
assert_eq!(message.group(), u4::new(0xC));
20+
assert_eq!(message.control(), u7::new(0x36));
21+
assert_eq!(message.control_data(), u7::new(0x37));
1822
```
1923

2024
## Channeled

src/channel_voice2/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
MIDI 2.0 Channel Voice Messages
2+
3+
## Basic Usage
4+
5+
```rust
6+
use midi2::{
7+
prelude::*,
8+
channel_voice2::NoteOn,
9+
};
10+
11+
let mut message = ControlChange::<[u32; 4]>::new();
12+
message.set_channel(u4::new(0xA));
13+
message.set_group(u4::new(0xC));
14+
message.set_control(u7::new(0x36));
15+
message.set_control_data(u7::new(0x37));
16+
17+
assert_eq!(message.data(), &[0x2CBA_3637]);
18+
```
19+
20+
## Channeled
21+
22+
`channel_voice1` messages are [Channeled](crate::Channeled).
23+
24+
## Grouped
25+
26+
`channel_voice1` messages are [Grouped](crate::Grouped)
27+
when backed with [Ump](crate::buffer::Ump) buffers.
28+
29+
## Aggregate Message
30+
31+
There is a single aggregate [ChannelVoice1] enum type which
32+
can represent an arbitrary `channel_voice1` message.
33+
34+
```rust
35+
use midi2::{
36+
prelude::*,
37+
channel_voice1::ChannelVoice1,
38+
};
39+
40+
let mut message = ChannelVoice1::try_from(&[0x2CBA_3637_u32][..]).expect("Valid data");
41+
42+
match message {
43+
ChannelVoice1::ChannelPressure(m) => println!("channel_pressure {:?}", m.data()),
44+
ChannelVoice1::ControlChange(m) => println!("control_change {:?}", m.data()),
45+
ChannelVoice1::KeyPressure(m) => println!("key_pressure {:?}", m.data()),
46+
ChannelVoice1::NoteOff(m) => println!("note_off {:?}", m.data()),
47+
ChannelVoice1::NoteOn(m) => println!("note_on {:?}", m.data()),
48+
ChannelVoice1::PitchBend(m) => println!("pitch_bend {:?}", m.data()),
49+
ChannelVoice1::ProgramChange(m) => println!("program_change {:?}", m.data()),
50+
}
51+
```
52+
53+
## Generic Over [Unit](crate::buffer::Unit)
54+
55+
`channel_voice1` messages can also be represented with [Bytes](crate::buffer::Bytes) buffers
56+
as well as [Ump](crate::buffer::Ump) buffers.
57+
58+
```rust
59+
use midi2::{
60+
prelude::*,
61+
channel_voice1::ControlChange,
62+
};
63+
64+
let mut message = ControlChange::<[u8; 3]>::new();
65+
message.set_channel(u4::new(0xA));
66+
message.set_control(u7::new(0x36));
67+
message.set_control_data(u7::new(0x37));
68+
69+
assert_eq!(message.data(), &[0xBA, 0x36, 0x37]);
70+
```
71+
72+
## Fixed Size
73+
74+
All `channel_voice1` messages are Fixed size.
75+
76+
```rust
77+
use midi2::channel_voice1::KeyPressure;
78+
79+
80+
// All channel_voice1 bytes-backed messages fit into a `[u8; 3]`
81+
let _ = KeyPressure::<[u8; 3]>::new();
82+
83+
// All channel_voice1 ump-backed messages fit into a `[u32; 1]`
84+
let _ = KeyPressure::<[u32; 1]>::new();
85+
```

0 commit comments

Comments
 (0)