-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathControl.h
More file actions
40 lines (37 loc) · 953 Bytes
/
Control.h
File metadata and controls
40 lines (37 loc) · 953 Bytes
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
#ifndef __Control_h__
#define __Control_h__
#include "Patch.h"
#include "message.h"
#include "main.h"
template<PatchParameterId PID>
class Control {
public:
Control<PID>(const float value=0){
ASSERT(PID < getProgramVector()->parameters_size, "Invalid parameter ID");
set(value);
}
void set(const float value){
#ifdef USE_LEGACY_FIRMWARE
if(getProgramVector()->isLegacyFirmware() && PID < 4)
doSetPatchParameter(PID, 4095 - (int16_t)(value*4096.0f));
else
#endif
doSetPatchParameter(PID, (int16_t)(value*4096));
}
float get(){
#ifdef USE_LEGACY_FIRMWARE
if(getProgramVector()->isLegacyFirmware() && PID < 4)
return (4095 - getProgramVector()->parameters[PID])/4096.0f;
else
#endif
return getProgramVector()->parameters[PID]/4096.0f;
}
Control<PID>& operator=(const float value){
set(value);
return *this;
}
operator float(){
return get();
}
};
#endif /* __Control_h__ */