-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSystem.h
More file actions
174 lines (140 loc) · 3.59 KB
/
Copy pathSystem.h
File metadata and controls
174 lines (140 loc) · 3.59 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Copyright (C) 2022-2025 Theo Niessink <theo@taletn.com>
// This work is free. You can redistribute it and/or modify it under the
// terms of the Do What The Fuck You Want To Public License, Version 2,
// as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
#pragma once
#include <assert.h>
#include "WDL/wdltypes.h"
namespace TG101 {
enum
{ /*
kDeviceNo1 = 0,
...
kDeviceNo16 = 15, */
kDeviceNoAll = 16
};
typedef int EEnableMidiMsg; enum
{
kEnableSysEx = 0,
kEnableProgramChange = 1,
kEnableControlChange = 2
};
typedef int ESoundModuleMode; enum
{
kModeGeneralMidi = 0,
kModeDiskOrchestra = 1,
kModeCM64 = 2
};
typedef int EVelocityMeter; enum
{
kVelocityMeterOff = 0,
kVelocityMeterAuto = 1,
kVelocityMeterOn = 2
};
struct System
{
unsigned char mBuf[10];
void Init();
void Reset();
int GetMasterTune() const
{
return (unsigned char)(mBuf[0] << 4) | (mBuf[1] & 15);
}
inline int GetTranspose() const { return mBuf[2] & 127; }
int GetDeviceNo() const
{
const int byte = mBuf[3], nibble = byte & 15;
return byte == kDeviceNoAll ? byte : nibble;
}
inline bool IsEnabled(const EEnableMidiMsg idx) const
{
assert(idx >= kEnableSysEx && idx <= kEnableControlChange);
return !!mBuf[4 + (unsigned int)idx];
}
ESoundModuleMode GetSoundModuleMode() const
{
const int mode = mBuf[7];
return mode <= kModeCM64 ? mode : kModeGeneralMidi;
}
inline int GetMasterVolume() const { return mBuf[8] & 127; }
EVelocityMeter GetVelocityMeter() const
{
const int mode = mBuf[9];
return wdl_min(mode, kVelocityMeterOn);
}
void SetMasterTune(const int detune)
{
assert(detune >= 28 && detune <= 228);
mBuf[0] = (unsigned char)detune >> 4;
mBuf[1] = detune & 15;
}
inline void SetTranspose(const int shift)
{
assert(shift >= 40 && shift <= 88);
mBuf[2] = shift;
}
inline void SetDeviceNo(const int devNo)
{
assert(devNo >= 0 && devNo <= kDeviceNoAll);
mBuf[3] = devNo;
}
inline bool SetEnable(const EEnableMidiMsg idx, const bool enable)
{
assert(idx >= kEnableSysEx && idx <= kEnableControlChange);
return mBuf[4 + (unsigned int)idx] = enable;
}
inline void SetSoundModuleMode(const ESoundModuleMode mode)
{
assert(mode >= kModeGeneralMidi && mode <= kModeCM64);
mBuf[7] = mode;
}
inline void SetMasterVolume(const int vol)
{
assert(vol >= 0 && vol <= 127);
mBuf[8] = vol;
}
inline void SetVelocityMeter(const EVelocityMeter meter)
{
assert(meter >= kVelocityMeterOff && meter <= kVelocityMeterOn);
mBuf[9] = meter;
}
};
typedef int EReverbType; enum
{
kReverbHall1 = 0,
kReverbHall2 = 1,
kReverbRoom1 = 2,
kReverbRoom2 = 3,
kReverbPlate1 = 4,
kReverbPlate2 = 5,
kReverbDelay1 = 6,
kReverbDelay2 = 7,
kNumReverbTypes = 8
};
struct MultiCommon
{
unsigned char mBuf[6];
void Init();
void Reset();
inline EReverbType GetReverbType() const { return mBuf[0] & 7; }
inline int GetReverbTime() const { return mBuf[1] & 127; }
inline int GetReverbOutputLevel() const { return mBuf[2] & 127; }
inline void SetReverbType(const EReverbType type)
{
assert(type >= kReverbHall1 && type <= kReverbDelay2);
mBuf[0] = type;
}
inline void SetReverbTime(const int time)
{
assert(time >= 3 && time <= 54);
mBuf[1] = time;
}
inline void SetReverbOutputLevel(const int level)
{
assert(level >= 24 && level <= 70);
mBuf[2] = level;
}
static int GetReverbTime(EReverbType type);
static int GetReverbOutputLevel(EReverbType type);
};
} // namespace TG101