-
Notifications
You must be signed in to change notification settings - Fork 18
/
Settings.h
201 lines (171 loc) · 6.15 KB
/
Settings.h
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#define SETTINGSOPTIONSNO 11
#define SETTINGSVALUESNO 18//Maximum number of settings option values needed
int settingsValueIndex = 0;//currently selected settings option value index
struct SettingsOption
{
char * option;//Settings option string
char *value[SETTINGSVALUESNO];//Array of strings of settings option values
int handler;//Function to handle the values for this settings option
int currentIndex;//Function to array index of current value for this settings option
};
void settingsMIDICh(char * value);
void settingsMIDIOutCh(char * value);
void settingsVelocitySens(char * value);
void settingsKeyTracking(char * value);
void settingsPitchBend(char * value);
void settingsModWheelDepth(char * value);
void settingsEncoderDir(char * value);
void settingsPickupEnable(char * value);
void settingsBassEnhanceEnable(char * value);
void settingsScopeEnable(char * value);
void settingsVUEnable(char * value);
void settingsHandler(char * s, void (*f)(char*));
int currentIndexMIDICh();
int currentIndexVelocitySens();
int currentIndexKeyTracking();
int currentIndexPitchBend();
int currentIndexModWheelDepth();
int currentIndexEncoderDir();
int currentIndexPickupEnable();
int currentIndexBassEnhanceEnable();
int currentIndexScopeEnable();
int currentIndexVUEnable();
int getCurrentIndex(int (*f)());
void settingsMIDICh(char * value) {
if (strcmp(value, "ALL") == 0) {
midiChannel = MIDI_CHANNEL_OMNI;
} else {
midiChannel = atoi(value);
}
storeMidiChannel(midiChannel);
}
void settingsMIDIOutCh(char * value) {
if (strcmp(value, "Off") == 0) {
midiOutCh = 0;
} else {
midiOutCh = atoi(value);
}
storeMidiOutCh(midiOutCh);
}
void settingsVelocitySens(char * value) {
if (strcmp(value, "Off") == 0) {
velocitySens = 0;
} else {
velocitySens = atoi(value);
}
}
void settingsKeyTracking(char * value) {
if (strcmp(value, "None") == 0) keytrackingAmount = 0;
if (strcmp(value, "Half") == 0) keytrackingAmount = 0.5;
if (strcmp(value, "Full") == 0) keytrackingAmount = 1.0;
}
void settingsPitchBend(char * value) {
pitchBendRange = atoi(value);
storePitchBendRange(pitchBendRange);
}
void settingsModWheelDepth(char * value) {
modWheelDepth = atoi(value) / 10.0f;
storeModWheelDepth(modWheelDepth);
}
void settingsEncoderDir(char * value) {
if (strcmp(value, "Type 1") == 0) {
encCW = true;
} else {
encCW = false;
}
storeEncoderDir(encCW ? 1 : 0);
}
void settingsBassEnhanceEnable(char * value) {
if (strcmp(value, "Off") == 0) {
sgtl5000_1.enhanceBassDisable();
storeBassEnhanceEnable(0);
} else {
sgtl5000_1.enhanceBassEnable();
storeBassEnhanceEnable(1);
}
}
void settingsPickupEnable(char * value) {
if (strcmp(value, "Off") == 0) {
pickUp = false;
} else {
pickUp = true;
}
storePickupEnable(pickUp ? 1 : 0);
}
void settingsScopeEnable(char * value) {
if (strcmp(value, "Off") == 0) {
enableScope(false);
storeScopeEnable(0);
} else {
enableScope(true);
storeScopeEnable(1);
}
}
void settingsVUEnable(char * value) {
if (strcmp(value, "Off") == 0) {
vuMeter = false;
storeVUEnable(0);
} else {
vuMeter = true;
storeVUEnable(1);
}
}
//Takes a pointer to a specific method for the settings option and invokes it.
void settingsHandler(char * s, void (*f)(char*) ) {
f(s);
}
int currentIndexMIDICh() {
return getMIDIChannel();
}
int currentIndexMIDIOutCh() {
return getMIDIOutCh();
}
int currentIndexVelocitySens() {
return velocitySens;
}
int currentIndexKeyTracking() {
if (keytrackingAmount == 0.0f) return 0;
if (keytrackingAmount == 0.5f) return 1;
if (keytrackingAmount == 1.0f) return 2;
return 0;
}
int currentIndexPitchBend() {
return getPitchBendRange() - 1;
}
int currentIndexModWheelDepth() {
return (getModWheelDepth() * 10) - 1;
}
int currentIndexEncoderDir() {
return getEncoderDir() ? 0 : 1;
}
int currentIndexPickupEnable() {
return getPickupEnable() ? 1 : 0;
}
int currentIndexBassEnhanceEnable() {
return getBassEnhanceEnable() ? 1 : 0;
}
//Takes a pointer to a specific method for the current settings option value and invokes it.
int getCurrentIndex(int (*f)() ) {
return f();
}
int currentIndexScopeEnable() {
return getScopeEnable() ? 1 : 0;
}
int currentIndexVUEnable() {
return getVUEnable() ? 1 : 0;
}
CircularBuffer<SettingsOption, SETTINGSOPTIONSNO> settingsOptions;
// add settings to the circular buffer
void setUpSettings() {
settingsOptions.push(SettingsOption{"MIDI Ch.", {"All", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", '\0'}, settingsMIDICh, currentIndexMIDICh});
settingsOptions.push(SettingsOption{"Vel. Sens.", {"Off", "1", "2", "3", "4", '\0'}, settingsVelocitySens, currentIndexVelocitySens});
settingsOptions.push(SettingsOption{"Key Tracking", {"None", "Half", "Full", '\0'}, settingsKeyTracking, currentIndexKeyTracking});
settingsOptions.push(SettingsOption{"Pitch Bend", {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", '\0'}, settingsPitchBend, currentIndexPitchBend});
settingsOptions.push(SettingsOption{"MW Depth", {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", '\0'}, settingsModWheelDepth, currentIndexModWheelDepth});
settingsOptions.push(SettingsOption{"MIDI Out Ch.", {"Off", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", '\0'}, settingsMIDIOutCh, currentIndexMIDIOutCh});
settingsOptions.push(SettingsOption{"Encoder", {"Type 1", "Type 2", '\0'}, settingsEncoderDir, currentIndexEncoderDir});
settingsOptions.push(SettingsOption{"Pick-up", {"Off", "On", '\0'}, settingsPickupEnable, currentIndexPickupEnable});
settingsOptions.push(SettingsOption{"Bass Enh.", {"Off", "On", '\0'}, settingsBassEnhanceEnable, currentIndexBassEnhanceEnable});
settingsOptions.push(SettingsOption{"Oscilloscope", {"Off", "On", '\0'}, settingsScopeEnable, currentIndexScopeEnable});
settingsOptions.push(SettingsOption{"VU Meter", {"Off", "On", '\0'}, settingsVUEnable, currentIndexVUEnable});
}