Skip to content

Commit 1f9ca91

Browse files
author
Franz Detro
committed
improve C++ code formatting
1 parent 7e7e54b commit 1f9ca91

11 files changed

+591
-447
lines changed

docs/channel_voice_message.md

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,71 +13,87 @@ Code examples can be found in [`channel_voice_message.examples.cpp`](channel_voi
1313

1414
Available filter functions are:
1515

16-
bool is_channel_voice_message_with_status(const universal_packet&, status_t);
17-
18-
bool is_note_on_message(const universal_packet&);
19-
bool is_note_off_message(const universal_packet&);
20-
bool is_poly_pressure_message(const universal_packet&);
21-
bool is_control_change_message(const universal_packet&);
22-
bool is_program_change_message(const universal_packet&);
23-
bool is_channel_pressure_message(const universal_packet&);
24-
bool is_channel_pitch_bend_message(const universal_packet&);
16+
```cpp
17+
bool is_channel_voice_message_with_status(const universal_packet&, status_t);
18+
19+
bool is_note_on_message(const universal_packet&);
20+
bool is_note_off_message(const universal_packet&);
21+
bool is_poly_pressure_message(const universal_packet&);
22+
bool is_control_change_message(const universal_packet&);
23+
bool is_program_change_message(const universal_packet&);
24+
bool is_channel_pressure_message(const universal_packet&);
25+
bool is_channel_pitch_bend_message(const universal_packet&);
26+
````
2527
2628
Additionally, one may use
2729
28-
bool is_note_on_with_attribute(const universal_packet&, uint8_t);
29-
bool is_note_off_with_attribute(const universal_packet&, uint8_t);
30-
bool is_note_on_with_pitch_7_9(const universal_packet&);
30+
```cpp
31+
bool is_note_on_with_attribute(const universal_packet&, uint8_t);
32+
bool is_note_off_with_attribute(const universal_packet&, uint8_t);
33+
bool is_note_on_with_pitch_7_9(const universal_packet&);
34+
```
3135
3236
to check for MIDI 2 note messages with attributes.
3337
3438
## Note Message Properties
3539
3640
The following functions are available to extract properties from Note messages:
3741
38-
note_nr_t get_note_nr(const universal_packet&);
39-
pitch_7_9 get_note_pitch(const universal_packet&);
40-
velocity get_note_velocity(const universal_packet&);
42+
```cpp
43+
note_nr_t get_note_nr(const universal_packet&);
44+
pitch_7_9 get_note_pitch(const universal_packet&);
45+
velocity get_note_velocity(const universal_packet&);
46+
```
4147
4248
`get_note_nr` is applicable to _Poly Pressure_ and _Per-Note Controller_ messages, too.
4349
4450
Additionally, one may use
4551
46-
uint8_t get_midi2_note_attribute(const universal_packet&);
47-
uint16_t get_midi2_note_attribute_data(const universal_packet&);
52+
```cpp
53+
uint8_t get_midi2_note_attribute(const universal_packet&);
54+
uint16_t get_midi2_note_attribute_data(const universal_packet&);
55+
```
4856
4957
to retrieve Per Note Attribute type and data.
5058
5159
## Controller Message Properties
5260
5361
Use
5462
55-
controller_t get_controller_nr(const universal_packet&);
56-
controller_value get_controller_value(const universal_packet&);
63+
```cpp
64+
controller_t get_controller_nr(const universal_packet&);
65+
controller_value get_controller_value(const universal_packet&);
66+
```
5767
5868
to extract _Control Change_ message properties.
5969
6070
`get_controller_value` is applicable to _Poly Pressure_, _Registered/Assignable Controller_ and _Per-Note Controller_ messages, too.
6171
6272
Use these functions to retrieve properties of specific messages:
6373
64-
controller_value get_poly_pressure_value(const universal_packet&);
65-
uint7_t get_program_value(const universal_packet&);
66-
controller_value get_channel_pressure_value(const universal_packet&);
67-
pitch_bend get_channel_pitch_bend_value(const universal_packet&);
74+
```cpp
75+
controller_value get_poly_pressure_value(const universal_packet&);
76+
uint7_t get_program_value(const universal_packet&);
77+
controller_value get_channel_pressure_value(const universal_packet&);
78+
pitch_bend get_channel_pitch_bend_value(const universal_packet&);
79+
```
6880
6981
## Conversion between Protocols
7082
7183
One may use
7284
73-
std::optional<midi1_channel_voice_message>
74-
as_midi1_channel_voice_message(const midi2_channel_voice_message_view&);
85+
```cpp
86+
std::optional<midi1_channel_voice_message>
87+
as_midi1_channel_voice_message(const midi2_channel_voice_message_view&);
88+
```
7589
7690
to convert a MIDI 2 Channel Voice Message to its MIDI 1 counterpart and
7791
78-
std::optional<midi2_channel_voice_message>
79-
as_midi2_channel_voice_message(const midi1_channel_voice_message_view&);
92+
```cpp
93+
std::optional<midi2_channel_voice_message>
94+
as_midi2_channel_voice_message(const midi1_channel_voice_message_view&);
95+
```
8096
8197
to convert a MIDI 1 Channel Voice Message to its MIDI 2 counterpart.
8298
83-
**Note:** MIDI 1 <-> MIDI 2 translation rules do require some sequences of MIDI 1 messages to be translated to single MIDI 2 messages and vice versa. The above mentioned functions do not follow these rules. Actually they filter some _Control Change_ messages (mostly related to (N)RPNs) and cannot handle MIDI 2 _Program Change_ messages with `bank` data.
99+
**Note:** MIDI 1 <-> MIDI 2 translation rules do require some sequences of MIDI 1 messages to be translated to single MIDI 2 messages and vice versa. The above mentioned functions do not follow these rules. Actually they filter some _Control Change_ messages (mostly related to (N)RPNs) and cannot handle MIDI 2 _Program Change_ messages with `bank` data.

docs/data_message.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,75 @@ Code examples can be found in [`data_message.examples.cpp`](data_message.example
66

77
Data Messages are represented by a
88

9-
struct data_message : universal_packet
10-
{
11-
explicit data_message(status_t);
12-
};
9+
```cpp
10+
struct data_message : universal_packet
11+
{
12+
explicit data_message(status_t);
13+
};
14+
```
1315

1416
Usually one will not use this class directly, but instead
1517

16-
struct sysex7_packet : data_message
17-
{
18-
sysex7_packet(status_t, group_t);
18+
```cpp
19+
struct sysex7_packet : data_message
20+
{
21+
sysex7_packet(status_t, group_t);
1922

20-
packet_format format() const;
23+
packet_format format() const;
2124

22-
uint8_t payload_byte(size_t b) const;
23-
void set_payload_byte(size_t, uint8_t);
25+
uint8_t payload_byte(size_t b) const;
26+
void set_payload_byte(size_t, uint8_t);
2427

25-
size_t payload_size() const;
26-
void set_payload_size(size_t);
28+
size_t payload_size() const;
29+
void set_payload_size(size_t);
2730

28-
void add_payload_byte(uint8_t);
29-
};
31+
void add_payload_byte(uint8_t);
32+
};
33+
```
3034
3135
A `sysex7_packet` can hold a payload of up to six bytes and provides APIs to add or read the payload bytes. Be aware that the payload shall only be 7 bit data.
3236
3337
Instead of using sysex7_packet constructors one can create messages using factory functions:
3438
35-
sysex7_packet make_sysex7_complete_packet(group_t);
36-
sysex7_packet make_sysex7_start_packet(group_t);
37-
sysex7_packet make_sysex7_continue_packet(group_t);
38-
sysex7_packet make_sysex7_end_packet(group_t);
39+
```cpp
40+
sysex7_packet make_sysex7_complete_packet(group_t);
41+
sysex7_packet make_sysex7_start_packet(group_t);
42+
sysex7_packet make_sysex7_continue_packet(group_t);
43+
sysex7_packet make_sysex7_end_packet(group_t);
44+
```
3945

4046
Filtering of Data Messages can be done checking `universal_packet::type()` against
4147
`packet_type::data` or use
4248

43-
bool is_data_message(const universal_packet&);
44-
bool is_sysex7_packet(const universal_packet&);
49+
```cpp
50+
bool is_data_message(const universal_packet&);
51+
bool is_sysex7_packet(const universal_packet&);
52+
```
4553
4654
### SysEx7 Packet View
4755
4856
Once validated being a `sysex7` packet one can create a `sysex7_packet_view`
4957
for a `universal_packet`:
5058
51-
struct sysex7_packet_view
52-
{
53-
explicit sysex7_packet_view(const universal_packet&);
59+
```cpp
60+
struct sysex7_packet_view
61+
{
62+
explicit sysex7_packet_view(const universal_packet&);
5463
55-
group_t group() const;
56-
status_t status() const;
57-
packet_format format() const;
58-
size_t payload_size() const;
59-
uint8_t payload_byte(size_t b) const;
60-
};
64+
group_t group() const;
65+
status_t status() const;
66+
packet_format format() const;
67+
size_t payload_size() const;
68+
uint8_t payload_byte(size_t b) const;
69+
};
70+
```
6171

6272
View members provide accessors to the properties of the message.
6373

6474
The additional
6575

66-
std::optional<sysex7_packet_view> as_sysex7_packet_view(const universal_packet&);
76+
```cpp
77+
std::optional<sysex7_packet_view> as_sysex7_packet_view(const universal_packet&);
78+
```
6779
6880
helper allows to combine packet type check and view creation in a single statement.

docs/extended_data_message.md

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,34 @@ Code examples can be found in [`extended_data_message.examples.cpp`](extended_da
66

77
Extended Data Messages are represented by a
88

9-
struct extended_data_message : universal_packet
10-
{
11-
explicit extended_data_message(status_t);
12-
};
9+
```cpp
10+
struct extended_data_message : universal_packet
11+
{
12+
explicit extended_data_message(status_t);
13+
};
14+
```
1315

1416
Usually one will not use this class directly, but instead
1517

16-
struct sysex8_packet : extended_data_message
17-
{
18-
sysex8_packet(status_t, uint8_t stream_id, group_t);
18+
```cpp
19+
struct sysex8_packet : extended_data_message
20+
{
21+
sysex8_packet(status_t, uint8_t stream_id, group_t);
1922

20-
packet_format format() const;
23+
packet_format format() const;
2124

22-
uint8_t stream_id() const;
23-
void set_stream_id(uint8_t);
25+
uint8_t stream_id() const;
26+
void set_stream_id(uint8_t);
2427

25-
uint8_t payload_byte(size_t b) const;
26-
void set_payload_byte(size_t, uint8_t);
28+
uint8_t payload_byte(size_t b) const;
29+
void set_payload_byte(size_t, uint8_t);
2730

28-
size_t payload_size() const;
29-
void set_payload_size(size_t);
31+
size_t payload_size() const;
32+
void set_payload_size(size_t);
3033

31-
void add_payload_byte(uint8_t);
32-
};
34+
void add_payload_byte(uint8_t);
35+
};
36+
```
3337
3438
A `sysex8_packet` can hold a payload of up to 13 bytes and provides APIs to add or read the payload bytes.
3539
System Exclusive 8 packets payload is allowed to be 8 bit, different to traditional MIDI System Exclusive (7 bit).
@@ -38,37 +42,45 @@ In MIDI 2 is allowed to have multiple parallel System Exclusive 8 streams runnin
3842
3943
Instead of using sysex8_packet constructors one can create messages using factory functions:
4044
41-
sysex8_packet make_sysex8_complete_packet(uint8_t stream_id, group_t);
42-
sysex8_packet make_sysex8_start_packet(uint8_t stream_id, group_t);
43-
sysex8_packet make_sysex8_continue_packet(uint8_t stream_id, group_t);
44-
sysex8_packet make_sysex8_end_packet(uint8_t stream_id, group_t);
45+
```cpp
46+
sysex8_packet make_sysex8_complete_packet(uint8_t stream_id, group_t);
47+
sysex8_packet make_sysex8_start_packet(uint8_t stream_id, group_t);
48+
sysex8_packet make_sysex8_continue_packet(uint8_t stream_id, group_t);
49+
sysex8_packet make_sysex8_end_packet(uint8_t stream_id, group_t);
50+
```
4551

4652
Filtering of Extended Data Messages can be done checking `universal_packet::type()` against
4753
`packet_type::extended_data` or use
4854

49-
bool is_extended_data_message(const universal_packet&);
50-
bool is_sysex8_packet(const universal_packet&);
55+
```cpp
56+
bool is_extended_data_message(const universal_packet&);
57+
bool is_sysex8_packet(const universal_packet&);
58+
```
5159
5260
### SysEx8 Packet View
5361
5462
Once validated being a `sysex8` packet one can create a `sysex8_packet_view`
5563
for a `universal_packet`:
5664
57-
struct sysex8_packet_view
58-
{
59-
explicit sysex8_packet_view(const universal_packet&);
65+
```cpp
66+
struct sysex8_packet_view
67+
{
68+
explicit sysex8_packet_view(const universal_packet&);
6069
61-
group_t group() const;
62-
packet_format format() const;
63-
uint8_t stream_id() const;
64-
size_t payload_size() const;
65-
uint8_t payload_byte(size_t b) const;
66-
};
70+
group_t group() const;
71+
packet_format format() const;
72+
uint8_t stream_id() const;
73+
size_t payload_size() const;
74+
uint8_t payload_byte(size_t b) const;
75+
};
76+
```
6777

6878
View members provide accessors to the properties of the message.
6979

7080
The additional
7181

72-
std::optional<sysex8_packet_view> as_sysex8_packet_view(const universal_packet&);
82+
```cpp
83+
std::optional<sysex8_packet_view> as_sysex8_packet_view(const universal_packet&);
84+
```
7385
7486
helper allows to combine packet type check and view creation in a single statement.

docs/flex_data_message.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Code examples can be found in [`flex_data_message.examples.cpp`](flex_data_messa
44

55
## Message Creation and Filtering
66

7-
Flex Data Messages are represented by a
7+
_Flex Data Messages_ are represented by a
88

99
```cpp
1010
struct flex_data_message : universal_packet
@@ -59,7 +59,7 @@ Be aware that a single `flex_data_text_message` can hold only 12 characters, if
5959
using the `packet_format` mechanism (`start`, `cont`, `end`).
6060

6161
Be also aware that the `denominator` in a _Set Time Signature_ message is expressed as a negative power of two, meaning that
62-
`2` represents a quarter note, `3` and eights note and so on.
62+
`2` represents a quarter note, `3` an eights note and so on.
6363

6464
Filtering of _Flex Data Messages_ can be done checking `universal_packet::type()` against
6565
`packet_type::flex_data` or use

0 commit comments

Comments
 (0)