@@ -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" ));
@@ -196,11 +192,10 @@ class Surface: public IReaperControlSurface {
196
192
197
193
virtual void SetSurfaceSelected (MediaTrack* track, bool selected) override {
198
194
if (!selected || !settings::reportSurfaceChanges ||
199
- // REAPER calls this a *lot*, even if the track was already selected; e.g.
200
- // for mute, arm, solo, etc. Ignore this if we were already told about
201
- // this track being selected.
202
- track == lastSelectedTrack
203
- ) {
195
+ // REAPER calls this a *lot*, even if the track was already selected; e.g.
196
+ // for mute, arm, solo, etc. Ignore this if we were already told about
197
+ // this track being selected.
198
+ track == lastSelectedTrack) {
204
199
return ;
205
200
}
206
201
// Cache the track even if we're handling a command because that command
@@ -243,8 +238,7 @@ class Surface: public IReaperControlSurface {
243
238
s << chunk << " " ;
244
239
}
245
240
this ->lastParam = param;
246
- TrackFX_FormatParamValueNormalized (track, fx, param, normVal, chunk,
247
- sizeof (chunk));
241
+ TrackFX_FormatParamValueNormalized (track, fx, param, normVal, chunk, sizeof (chunk));
248
242
if (chunk[0 ]) {
249
243
s << chunk;
250
244
} else {
@@ -267,10 +261,10 @@ class Surface: public IReaperControlSurface {
267
261
private:
268
262
bool wasCausedByCommand () {
269
263
return isHandlingCommand ||
270
- // Sometimes, REAPER updates control surfaces after a command rather than
271
- // during. If the last command OSARA handled was <= 50 ms ago, we assume
272
- // this update was caused by that command.
273
- GetTickCount () - lastCommandTime <= 50 ;
264
+ // Sometimes, REAPER updates control surfaces after a command rather than
265
+ // during. If the last command OSARA handled was <= 50 ms ago, we assume
266
+ // this update was caused by that command.
267
+ GetTickCount () - lastCommandTime <= 50 ;
274
268
}
275
269
276
270
// Used for parameters we don't cache such as volume, pan and FX parameters.
@@ -285,14 +279,14 @@ class Surface: public IReaperControlSurface {
285
279
// Only handle param changes if the last change was 100ms or more ago.
286
280
return now - prevChangeTime >= 100 ;
287
281
}
282
+
288
283
DWORD lastParamChangeTime = 0 ;
289
284
290
285
bool reportTrackIfDifferent (MediaTrack* track, ostringstream& output) {
291
286
bool different = track != this ->lastChangedTrack ;
292
287
if (different) {
293
288
this ->lastChangedTrack = track;
294
- int trackNum = (int )(size_t )GetSetMediaTrackInfo (track, " IP_TRACKNUMBER" ,
295
- nullptr );
289
+ int trackNum = (int )(size_t )GetSetMediaTrackInfo (track, " IP_TRACKNUMBER" , nullptr );
296
290
if (trackNum <= 0 ) {
297
291
output << translate (" master" );
298
292
} else {
0 commit comments