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
8
#include < WDL/db2val.h>
9
+
13
10
#include < cstdint>
14
- #include " osara.h"
11
+ #include < iomanip>
12
+ #include < map>
13
+ #include < sstream>
14
+ #include < string>
15
+
15
16
#include " config.h"
16
- #include " paramsUi.h"
17
17
#include " midiEditorCommands.h"
18
+ #include " osara.h"
19
+ #include " paramsUi.h"
18
20
#include " translation.h"
19
21
20
22
using namespace std ;
@@ -39,7 +41,7 @@ const uint8_t TC_UNARMED = 1 << 5;
39
41
template <uint8_t enableFlag, uint8_t disableFlag>
40
42
class TrackCacheState {
41
43
public:
42
- TrackCacheState (uint8_t & value): value(value) {}
44
+ TrackCacheState (uint8_t & value) : value(value) {}
43
45
44
46
// Check if a supplied new state has changed from the cached state.
45
47
bool hasChanged (bool isEnabled) {
@@ -64,9 +66,10 @@ class TrackCacheState {
64
66
uint8_t & value;
65
67
};
66
68
67
- /* ** A control surface to obtain certain info that can only be retrieved that way.
69
+ /* ** A control surface to obtain certain info that can only be retrieved that
70
+ * way.
68
71
*/
69
- class Surface : public IReaperControlSurface {
72
+ class Surface : public IReaperControlSurface {
70
73
public:
71
74
virtual const char * GetTypeString () override {
72
75
return " OSARA" ;
@@ -146,8 +149,8 @@ class Surface: public IReaperControlSurface {
146
149
return ;
147
150
}
148
151
auto cache = this ->cachedTrackState <TC_MUTED, TC_UNMUTED>(track);
149
- if (!isParamsDialogOpen && !this ->wasCausedByCommand () &&
150
- cache.hasChanged (mute)) {
152
+ if (!isParamsDialogOpen && !this ->wasCausedByCommand ()
153
+ && cache.hasChanged (mute)) {
151
154
ostringstream s;
152
155
this ->reportTrackIfDifferent (track, s);
153
156
s << (mute ? translate (" muted" ) : translate (" unmuted" ));
@@ -166,8 +169,8 @@ class Surface: public IReaperControlSurface {
166
169
return ;
167
170
}
168
171
auto cache = this ->cachedTrackState <TC_SOLOED, TC_UNSOLOED>(track);
169
- if (!isParamsDialogOpen && !this ->wasCausedByCommand () &&
170
- cache.hasChanged (solo)) {
172
+ if (!isParamsDialogOpen && !this ->wasCausedByCommand ()
173
+ && cache.hasChanged (solo)) {
171
174
ostringstream s;
172
175
this ->reportTrackIfDifferent (track, s);
173
176
s << (solo ? translate (" soloed" ) : translate (" unsoloed" ));
@@ -181,8 +184,8 @@ class Surface: public IReaperControlSurface {
181
184
return ;
182
185
}
183
186
auto cache = this ->cachedTrackState <TC_ARMED, TC_UNARMED>(track);
184
- if (!isParamsDialogOpen && !this ->wasCausedByCommand () &&
185
- cache.hasChanged (arm)) {
187
+ if (!isParamsDialogOpen && !this ->wasCausedByCommand ()
188
+ && cache.hasChanged (arm)) {
186
189
ostringstream s;
187
190
this ->reportTrackIfDifferent (track, s);
188
191
s << (arm ? translate (" armed" ) : translate (" unarmed" ));
@@ -199,8 +202,7 @@ class Surface: public IReaperControlSurface {
199
202
// REAPER calls this a *lot*, even if the track was already selected; e.g.
200
203
// for mute, arm, solo, etc. Ignore this if we were already told about
201
204
// this track being selected.
202
- track == lastSelectedTrack
203
- ) {
205
+ track == lastSelectedTrack) {
204
206
return ;
205
207
}
206
208
// Cache the track even if we're handling a command because that command
@@ -214,7 +216,8 @@ class Surface: public IReaperControlSurface {
214
216
postGoToTrack (0 , track);
215
217
}
216
218
217
- virtual int Extended (int call, void * parm1, void * parm2, void * parm3) override {
219
+ virtual int Extended (
220
+ int call, void * parm1, void * parm2, void * parm3) override {
218
221
if (call == CSURF_EXT_SETFXPARAM) {
219
222
if (!this ->shouldHandleParamChange ()) {
220
223
return 0 ; // Unsupported.
@@ -243,8 +246,8 @@ class Surface: public IReaperControlSurface {
243
246
s << chunk << " " ;
244
247
}
245
248
this ->lastParam = param;
246
- TrackFX_FormatParamValueNormalized (track, fx, param, normVal, chunk,
247
- sizeof (chunk));
249
+ TrackFX_FormatParamValueNormalized (
250
+ track, fx, param, normVal, chunk, sizeof (chunk));
248
251
if (chunk[0 ]) {
249
252
s << chunk;
250
253
} else {
@@ -276,14 +279,15 @@ class Surface: public IReaperControlSurface {
276
279
// Only handle param changes if the last change was 100ms or more ago.
277
280
return now - prevChangeTime >= 100 ;
278
281
}
282
+
279
283
DWORD lastParamChangeTime = 0 ;
280
284
281
285
bool reportTrackIfDifferent (MediaTrack* track, ostringstream& output) {
282
286
bool different = track != this ->lastChangedTrack ;
283
287
if (different) {
284
288
this ->lastChangedTrack = track;
285
- int trackNum = ( int )( size_t ) GetSetMediaTrackInfo (track, " IP_TRACKNUMBER " ,
286
- nullptr );
289
+ int trackNum =
290
+ ( int )( size_t ) GetSetMediaTrackInfo (track, " IP_TRACKNUMBER " , nullptr );
287
291
if (trackNum <= 0 ) {
288
292
output << translate (" master" );
289
293
} else {
0 commit comments