@@ -12,71 +12,73 @@ class Attack final : public Integer {
12
12
using Integer::Integer;
13
13
void readCurrentValue () override {
14
14
auto value = (uint64_t )soundEditor.currentModControllable ->compressor .getAttack ();
15
- this ->setValue (( value * ( kMaxMenuValue * 2 ) + 2147483648 ) >> 32 );
15
+ this ->setValue (value >> 24 );
16
16
}
17
17
void writeCurrentValue () override {
18
- if (this ->getValue () == kMaxMenuValue ) {
19
- soundEditor.currentModControllable ->compressor .setAttack (ONE_Q31);
20
- }
21
- else {
22
- q31_t knobPos = (uint32_t )this ->getValue () * (2147483648 / kMidMenuValue ) >> 1 ;
18
+ auto value = this ->getValue ();
19
+ if (value < kMaxKnobPos ) {
20
+ q31_t knobPos = lshiftAndSaturate<24 >(value);
23
21
soundEditor.currentModControllable ->compressor .setAttack (knobPos);
24
22
}
25
23
}
26
- [[nodiscard]] int32_t getMaxValue () const override { return kMaxMenuValue ; }
24
+ int32_t getDisplayValue () override { return soundEditor.currentModControllable ->compressor .getAttackMS (); }
25
+ const char * getUnit () override { return " MS" ; }
26
+ [[nodiscard]] int32_t getMaxValue () const override { return kMaxKnobPos ; }
27
27
};
28
28
class Release final : public Integer {
29
29
public:
30
30
using Integer::Integer;
31
31
void readCurrentValue () override {
32
32
auto value = (uint64_t )soundEditor.currentModControllable ->compressor .getRelease ();
33
- this ->setValue (( value * ( kMaxMenuValue * 2 ) + 2147483648 ) >> 32 );
33
+ this ->setValue (value >> 24 );
34
34
}
35
35
void writeCurrentValue () override {
36
- if (this ->getValue () == kMaxMenuValue ) {
37
- soundEditor.currentModControllable ->compressor .setRelease (ONE_Q31);
38
- }
39
- else {
40
- q31_t knobPos = (uint32_t )this ->getValue () * (2147483648 / kMidMenuValue ) >> 1 ;
36
+ auto value = this ->getValue ();
37
+ if (value < kMaxKnobPos ) {
38
+ q31_t knobPos = lshiftAndSaturate<24 >(value);
41
39
soundEditor.currentModControllable ->compressor .setRelease (knobPos);
42
40
}
43
41
}
44
- [[nodiscard]] int32_t getMaxValue () const override { return kMaxMenuValue ; }
42
+ int32_t getDisplayValue () override { return soundEditor.currentModControllable ->compressor .getReleaseMS (); }
43
+ const char * getUnit () override { return " MS" ; }
44
+ [[nodiscard]] int32_t getMaxValue () const override { return kMaxKnobPos ; }
45
45
};
46
46
class Ratio final : public Integer {
47
47
public:
48
48
using Integer::Integer;
49
49
void readCurrentValue () override {
50
50
auto value = (uint64_t )soundEditor.currentModControllable ->compressor .getRatio ();
51
- this ->setValue (( value * ( kMaxMenuValue * 2 ) + 2147483648 ) >> 32 );
51
+ this ->setValue (value >> 24 );
52
52
}
53
53
void writeCurrentValue () override {
54
- if (this ->getValue () == kMaxMenuValue ) {
55
- soundEditor.currentModControllable ->compressor .setRatio (ONE_Q31);
56
- }
57
- else {
58
- q31_t knobPos = (uint32_t )this ->getValue () * (2147483648 / kMidMenuValue ) >> 1 ;
54
+ auto value = this ->getValue ();
55
+ if (value < kMaxKnobPos ) {
56
+ q31_t knobPos = lshiftAndSaturate<24 >(value);
59
57
soundEditor.currentModControllable ->compressor .setRatio (knobPos);
60
58
}
61
59
}
62
- [[nodiscard]] int32_t getMaxValue () const override { return kMaxMenuValue ; }
60
+ int32_t getDisplayValue () override { return soundEditor.currentModControllable ->compressor .getRatioForDisplay (); }
61
+ const char * getUnit () override { return " : 1" ; }
62
+ [[nodiscard]] int32_t getMaxValue () const override { return kMaxKnobPos ; }
63
63
};
64
64
class SideHPF final : public Integer {
65
65
public:
66
66
using Integer::Integer;
67
67
void readCurrentValue () override {
68
68
auto value = (uint64_t )soundEditor.currentModControllable ->compressor .getSidechain ();
69
- this ->setValue (( value * ( kMaxMenuValue * 2 ) + 2147483648 ) >> 32 );
69
+ this ->setValue (value >> 24 );
70
70
}
71
71
void writeCurrentValue () override {
72
- if (this ->getValue () == kMaxMenuValue ) {
73
- soundEditor.currentModControllable ->compressor .setSidechain (ONE_Q31);
74
- }
75
- else {
76
- q31_t knobPos = (uint32_t )this ->getValue () * (2147483648 / kMidMenuValue ) >> 1 ;
72
+ auto value = this ->getValue ();
73
+ if (value < kMaxKnobPos ) {
74
+ q31_t knobPos = lshiftAndSaturate<24 >(value);
77
75
soundEditor.currentModControllable ->compressor .setSidechain (knobPos);
78
76
}
79
77
}
80
- [[nodiscard]] int32_t getMaxValue () const override { return kMaxMenuValue ; }
78
+ int32_t getDisplayValue () override {
79
+ return soundEditor.currentModControllable ->compressor .getSidechainForDisplay ();
80
+ }
81
+ const char * getUnit () override { return " HZ" ; }
82
+ [[nodiscard]] int32_t getMaxValue () const override { return kMaxKnobPos ; }
81
83
};
82
84
} // namespace deluge::gui::menu_item::audio_compressor
0 commit comments