Deluge Firmware 1.3.0
Build date: 2025.06.05
Loading...
Searching...
No Matches
compressor_values.h
1#pragma once
2#include "definitions_cxx.hpp"
3#include "dsp/compressor/rms_feedback.h"
4#include "gui/menu_item/decimal.h"
5#include "gui/menu_item/integer.h"
6#include "gui/ui/sound_editor.h"
7#include "model/drum/drum.h"
8#include "model/instrument/kit.h"
9#include "model/mod_controllable/mod_controllable_audio.h"
10#include "model/song/song.h"
11#include "modulation/params/param_set.h"
12#include "processing/sound/sound.h"
13#include "processing/sound/sound_drum.h"
14#include "util/fixedpoint.h"
15
16namespace deluge::gui::menu_item::audio_compressor {
17
19 using DecimalWithoutScrolling::DecimalWithoutScrolling;
20 void readCurrentValue() final {
21 uint64_t value = getCompressorValue();
22 this->setValue(value >> 24);
23 }
24 void writeCurrentValue() final {
25 auto value = this->getValue();
26 if (value >= kMaxKnobPos) {
27 value = kMaxKnobPos - 1;
28 }
29 q31_t knobPos = lshiftAndSaturate<24>(value);
30
31 // If affect-entire button held, do whole kit
32 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
33
34 Kit* kit = getCurrentKit();
35
36 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
37 if (thisDrum->type == DrumType::SOUND) {
38 auto* soundDrum = static_cast<SoundDrum*>(thisDrum);
39
40 setCompressorValue(knobPos, &soundDrum->compressor);
41 }
42 }
43 }
44 // Or, the normal case of just one sound
45 else {
46 setCompressorValue(knobPos, &soundEditor.currentModControllable->compressor);
47 }
48 }
49 virtual uint64_t getCompressorValue() = 0;
50 virtual void setCompressorValue(q31_t value, RMSFeedbackCompressor* compressor) = 0;
51 [[nodiscard]] int32_t getMaxValue() const final { return kMaxKnobPos; }
52 [[nodiscard]] int32_t getNumDecimalPlaces() const override { return 2; }
53 const char* getUnit() override { return "MS"; }
54};
55
56class Attack final : public CompressorValue {
57public:
58 using CompressorValue::CompressorValue;
59 uint64_t getCompressorValue() final { return (uint64_t)soundEditor.currentModControllable->compressor.getAttack(); }
60 void setCompressorValue(q31_t value, RMSFeedbackCompressor* compressor) final { compressor->setAttack(value); }
61 float getDisplayValue() final { return soundEditor.currentModControllable->compressor.getAttackMS(); }
62};
63class Release final : public CompressorValue {
64public:
65 using CompressorValue::CompressorValue;
66 uint64_t getCompressorValue() final {
67 return (uint64_t)soundEditor.currentModControllable->compressor.getRelease();
68 }
69 void setCompressorValue(q31_t value, RMSFeedbackCompressor* compressor) final { compressor->setRelease(value); }
70 float getDisplayValue() final { return soundEditor.currentModControllable->compressor.getReleaseMS(); }
71 [[nodiscard]] int32_t getNumDecimalPlaces() const final { return 1; }
72};
73class Ratio final : public CompressorValue {
74public:
75 using CompressorValue::CompressorValue;
76 uint64_t getCompressorValue() final { return (uint64_t)soundEditor.currentModControllable->compressor.getRatio(); }
77 void setCompressorValue(q31_t value, RMSFeedbackCompressor* compressor) final { compressor->setRatio(value); }
78 float getDisplayValue() final { return soundEditor.currentModControllable->compressor.getRatioForDisplay(); }
79 const char* getUnit() final { return " : 1"; }
80};
81class SideHPF final : public CompressorValue {
82public:
83 using CompressorValue::CompressorValue;
84 uint64_t getCompressorValue() final {
85 return (uint64_t)soundEditor.currentModControllable->compressor.getSidechain();
86 }
87 void setCompressorValue(q31_t value, RMSFeedbackCompressor* compressor) final { compressor->setSidechain(value); }
88 float getDisplayValue() final { return soundEditor.currentModControllable->compressor.getSidechainForDisplay(); }
89 const char* getUnit() final { return "HZ"; }
90};
91class Blend final : public CompressorValue {
92public:
93 using CompressorValue::CompressorValue;
94 uint64_t getCompressorValue() final {
95 return (uint64_t)soundEditor.currentModControllable->compressor.getBlend().raw();
96 }
97 void setCompressorValue(q31_t, RMSFeedbackCompressor* compressor) final {
98 auto value = this->getValue();
99
100 FixedPoint<31> knobPos = 1.f;
101 if (value < kMaxKnobPos) {
102 knobPos.raw() = lshiftAndSaturate<24>(value);
103 }
104 compressor->setBlend(knobPos);
105 }
106
107 float getDisplayValue() override { return soundEditor.currentModControllable->compressor.getBlendForDisplay(); }
108 const char* getUnit() override { return " %"; }
109 [[nodiscard]] int32_t getNumDecimalPlaces() const final { return 0; }
110 [[nodiscard]] int32_t getColumnSpan() const override { return 1; }
111};
112} // namespace deluge::gui::menu_item::audio_compressor
Definition drum.h:44
Fixed point number with a configurable number of fractional bits.
Definition fixedpoint.h:47
constexpr BaseType raw() const noexcept
Get the internal value.
Definition fixedpoint.h:232
Definition kit.h:34
Definition rms_feedback.h:26
constexpr int32_t setAttack(q31_t attack)
Definition rms_feedback.h:78
constexpr int32_t setSidechain(q31_t f)
Definition rms_feedback.h:138
constexpr int32_t setRatio(q31_t rat)
Definition rms_feedback.h:122
constexpr int32_t setRelease(q31_t release)
Definition rms_feedback.h:95
constexpr int32_t setBlend(FixedPoint< 31 > blend)
Definition rms_feedback.h:157
Definition sound_drum.h:28
Definition compressor_values.h:56
Definition compressor_values.h:91
int32_t getColumnSpan() const override
Get the number of occupied virtual columns in the horizontal menu.
Definition compressor_values.h:110
void readCurrentValue() final
Like readValueAgain, but does not redraw.
Definition compressor_values.h:20
Definition compressor_values.h:73
Definition compressor_values.h:63
Definition compressor_values.h:81