5
5
* License: GNU General Public License version 2.0
6
6
*/
7
7
8
- #include < string>
9
- #include < sstream>
10
- #include < iomanip>
11
- #include < map>
12
- #include < WDL/db2val.h>
13
- #include < cstdint>
14
- #include " osara.h"
15
8
#include " config.h"
16
- #include " paramsUi.h"
17
9
#include " midiEditorCommands.h"
10
+ #include " osara.h"
11
+ #include " paramsUi.h"
18
12
#include " translation.h"
13
+ #include < cstdint>
14
+ #include < iomanip>
15
+ #include < map>
16
+ #include < sstream>
17
+ #include < string>
18
+ #include < WDL/db2val.h>
19
19
20
20
using namespace std ;
21
21
@@ -36,10 +36,9 @@ const uint8_t TC_ARMED = 1 << 4;
36
36
const uint8_t TC_UNARMED = 1 << 5 ;
37
37
38
38
// Make it easier to manipulate these cached states.
39
- template <uint8_t enableFlag, uint8_t disableFlag>
40
- class TrackCacheState {
39
+ template <uint8_t enableFlag, uint8_t disableFlag> class TrackCacheState {
41
40
public:
42
- TrackCacheState (uint8_t & value): value(value) {}
41
+ TrackCacheState (uint8_t & value) : value(value) {}
43
42
44
43
// Check if a supplied new state has changed from the cached state.
45
44
bool hasChanged (bool isEnabled) {
@@ -66,7 +65,7 @@ class TrackCacheState {
66
65
67
66
/* ** A control surface to obtain certain info that can only be retrieved that way.
68
67
*/
69
- class Surface : public IReaperControlSurface {
68
+ class Surface : public IReaperControlSurface {
70
69
public:
71
70
virtual const char * GetTypeString () override {
72
71
return " OSARA" ;
@@ -146,8 +145,7 @@ class Surface: public IReaperControlSurface {
146
145
return ;
147
146
}
148
147
auto cache = this ->cachedTrackState <TC_MUTED, TC_UNMUTED>(track);
149
- if (!isParamsDialogOpen && !this ->wasCausedByCommand () &&
150
- cache.hasChanged (mute)) {
148
+ if (!isParamsDialogOpen && !this ->wasCausedByCommand () && cache.hasChanged (mute)) {
151
149
ostringstream s;
152
150
this ->reportTrackIfDifferent (track, s);
153
151
s << (mute ? translate (" muted" ) : translate (" unmuted" ));
@@ -166,8 +164,7 @@ class Surface: public IReaperControlSurface {
166
164
return ;
167
165
}
168
166
auto cache = this ->cachedTrackState <TC_SOLOED, TC_UNSOLOED>(track);
169
- if (!isParamsDialogOpen && !this ->wasCausedByCommand () &&
170
- cache.hasChanged (solo)) {
167
+ if (!isParamsDialogOpen && !this ->wasCausedByCommand () && cache.hasChanged (solo)) {
171
168
ostringstream s;
172
169
this ->reportTrackIfDifferent (track, s);
173
170
s << (solo ? translate (" soloed" ) : translate (" unsoloed" ));
@@ -181,8 +178,7 @@ class Surface: public IReaperControlSurface {
181
178
return ;
182
179
}
183
180
auto cache = this ->cachedTrackState <TC_ARMED, TC_UNARMED>(track);
184
- if (!isParamsDialogOpen && !this ->wasCausedByCommand () &&
185
- cache.hasChanged (arm)) {
181
+ if (!isParamsDialogOpen && !this ->wasCausedByCommand () && cache.hasChanged (arm)) {
186
182
ostringstream s;
187
183
this ->reportTrackIfDifferent (track, s);
188
184
s << (arm ? translate (" armed" ) : translate (" unarmed" ));
@@ -217,14 +213,14 @@ class Surface: public IReaperControlSurface {
217
213
virtual int Extended (int call, void * parm1, void * parm2, void * parm3) override {
218
214
if (call == CSURF_EXT_SETFXPARAM) {
219
215
if (!this ->shouldHandleParamChange ()) {
220
- return 0 ; // Unsupported.
216
+ return 0 ; // Unsupported.
221
217
}
222
218
auto track = (MediaTrack*)parm1;
223
219
int fx = *(int *)parm2 >> 16 ;
224
220
// Don't report parameter changes where they might already be reported by
225
221
// the UI.
226
222
if (isParamsDialogOpen || TrackFX_GetChainVisible (track) == fx) {
227
- return 0 ; // Unsupported.
223
+ return 0 ; // Unsupported.
228
224
}
229
225
int param = *(int *)parm2 & 0xFFFF ;
230
226
double normVal = *(double *)parm3;
@@ -243,16 +239,15 @@ class Surface: public IReaperControlSurface {
243
239
s << chunk << " " ;
244
240
}
245
241
this ->lastParam = param;
246
- TrackFX_FormatParamValueNormalized (track, fx, param, normVal, chunk,
247
- sizeof (chunk));
242
+ TrackFX_FormatParamValueNormalized (track, fx, param, normVal, chunk, sizeof (chunk));
248
243
if (chunk[0 ]) {
249
244
s << chunk;
250
245
} else {
251
246
s << normVal;
252
247
}
253
248
outputMessage (s);
254
249
}
255
- return 0 ; // Unsupported.
250
+ return 0 ; // Unsupported.
256
251
}
257
252
258
253
private:
@@ -276,14 +271,14 @@ class Surface: public IReaperControlSurface {
276
271
// Only handle param changes if the last change was 100ms or more ago.
277
272
return now - prevChangeTime >= 100 ;
278
273
}
274
+
279
275
DWORD lastParamChangeTime = 0 ;
280
276
281
277
bool reportTrackIfDifferent (MediaTrack* track, ostringstream& output) {
282
278
bool different = track != this ->lastChangedTrack ;
283
279
if (different) {
284
280
this ->lastChangedTrack = track;
285
- int trackNum = (int )(size_t )GetSetMediaTrackInfo (track, " IP_TRACKNUMBER" ,
286
- nullptr );
281
+ int trackNum = (int )(size_t )GetSetMediaTrackInfo (track, " IP_TRACKNUMBER" , nullptr );
287
282
if (trackNum <= 0 ) {
288
283
output << translate (" master" );
289
284
} else {
0 commit comments