-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsystem_message.examples.cpp
66 lines (55 loc) · 1.51 KB
/
system_message.examples.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <midi/system_message.h>
void system_message_examples()
{
using namespace midi;
auto a = make_system_message(0, system_status::clock);
if (is_system_message(a))
{
auto m = system_message_view{ a };
group_t g = m.group();
status_t s = m.status();
}
auto b = make_system_message(0, system_status::song_select, 44);
if (auto m = as_system_message_view(b))
{
group_t g = m->group();
status_t s = m->status();
uint7_t d1 = m->data_byte_1();
}
auto c = make_song_position_message(0, 0x1234);
if (auto m = as_system_message_view(c))
{
group_t g = m->group();
status_t s = m->status();
uint7_t d1 = m->data_byte_1();
uint7_t d2 = m->data_byte_2();
uint14_t pos = m->get_song_position();
}
}
void system_message_readme_code()
{
using namespace midi;
auto packet = make_system_message(0, system_status::song_select, 4);
if (packet.type() == packet_type::system)
{
auto m = system_message_view{ packet };
// access message data
if (m.status() == system_status::song_select)
{
auto song = m.data_byte_1();
}
}
if (auto m = as_system_message_view(packet))
{
// access message data
if (m->status() == system_status::song_position)
{
auto pos = m->get_song_position();
}
}
}
void run_system_message_examples()
{
system_message_examples();
system_message_readme_code();
}