aboutsummaryrefslogtreecommitdiffstats
path: root/daemon/src/types.h
blob: a5c6165dfc4ce617de8cf99636e6990a6191ec21 (plain)
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
#pragma once

#include "sender.h"

#include <cstdint>
#include <array>
#include <string>
#include <map>
#include <vector>
#include <functional>

namespace midi_router
{

enum class Message_Type
{
    NOTE_OFF = 0x8u,
    NOTE_ON = 0x9u,
    POLY_AT = 0xAu,
    CONTROL_CHANGE = 0xBu,
    PROGRAM_CHANGE = 0xCu,
    CHANNEL_AT = 0xDu,
    PITCH_WHEEL = 0xEu,

    CLOCK = 0xF8u,
    MEAS_END = 0xF9u,
    START = 0xFAu,
    CONTINUE = 0xFBu,
    STOP = 0xFCu,
};

using Device_Id = std::string;
using Device_Map = std::map<std::string, Device_Id>;
using Target_List = std::vector<std::reference_wrapper<Sender>>;
using Route_Map = std::map<Device_Id, std::map<Message_Type, Target_List>>;

struct Message
{
    Device_Id const * source_id;
    std::array<std::uint8_t, 3> bytes;

    Message_Type
    type() const
    {
        if ((bytes[0] & 0xF0) == 0xF0) return static_cast<Message_Type>(bytes[0]);
        else return static_cast<Message_Type>(bytes[0] >> 4);
    }
};

} // namespace midi_router