Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master compressor #630

Merged
merged 38 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d52b4e6
add env follower mode to sidechain compressor
m-m-adams Oct 15, 2023
db22570
use hold in comp
m-m-adams Oct 15, 2023
eae5f04
barebones working
m-m-adams Oct 16, 2023
a43066e
working comp, no controls
m-m-adams Oct 16, 2023
6fd19d9
scaled appropriately
m-m-adams Oct 16, 2023
dfe2914
editable ratio and threshold
m-m-adams Oct 17, 2023
0359f89
better shape
m-m-adams Oct 17, 2023
7073246
working attack and release controls
m-m-adams Oct 20, 2023
dec6b92
tweak attack and release minimums
m-m-adams Oct 20, 2023
8b87d10
auto makeup gain
m-m-adams Oct 20, 2023
7b5637e
clean up auto makeup gain
m-m-adams Oct 20, 2023
b35eb3b
saving and restoring parameters
m-m-adams Oct 20, 2023
1f0d1a5
working auto makeup gain
m-m-adams Oct 20, 2023
ac0fdf7
remove old comp
m-m-adams Oct 20, 2023
c466fea
show mode popup and add to community features
m-m-adams Oct 20, 2023
e7ebcef
remove remaining old master comp references
m-m-adams Oct 20, 2023
955909c
dbt format
m-m-adams Oct 20, 2023
97e99ac
fix gain scaling
m-m-adams Oct 21, 2023
ed2fd93
fix gain scaling properly
m-m-adams Oct 21, 2023
85fe37e
improve parameter scaling and makeup
m-m-adams Oct 21, 2023
9103238
set better defaults
m-m-adams Oct 21, 2023
1340af7
dbt format
m-m-adams Oct 22, 2023
c0d1785
gr to gainReduction
m-m-adams Oct 23, 2023
69255f0
fix volume drop again
m-m-adams Oct 23, 2023
64cf7a0
fix retroactive sidechain hits
m-m-adams Oct 23, 2023
2e9acef
improve gain scaling
m-m-adams Oct 24, 2023
2cb70a6
fix sidechain not releasing
m-m-adams Oct 24, 2023
5cf04ef
tweak makeup gain again
m-m-adams Oct 24, 2023
de31423
float division for speed and accuracy
m-m-adams Oct 24, 2023
85a737d
adjust ratio range
m-m-adams Oct 24, 2023
bba4426
tie threshold to song volume
m-m-adams Oct 24, 2023
dd61480
limiting rework
m-m-adams Oct 24, 2023
d91a33d
change popup
m-m-adams Oct 24, 2023
87310c0
format and correct gain
m-m-adams Oct 24, 2023
a5ff85c
slightly increase makeup gain to handle higher levels
m-m-adams Oct 25, 2023
94f9f2e
move limiter post envelope
m-m-adams Oct 25, 2023
9935fed
switch to feedback compression
m-m-adams Oct 25, 2023
5fcb228
format
m-m-adams Oct 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions docs/community_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ Here is a list of features that have been added to the firmware as a list, group
### 4.1 - Song View Features

#### 4.1.1 - Master Compressor
- ([#137]) In the Song view, select "AFFECT ENTIRE" and "SIDECHAIN" modulation button, and adjust the upper gold knob. Push the upper gold knob to switch to the next setting (Threshold (dB), Makeup Gain (dB), Attack (ms), Release (ms), Ratio, MIX). The LEDs next to the knob act as a gain reduction meter.
- ([#630]) In the Song view, select "AFFECT ENTIRE" and "SIDECHAIN" modulation button, and adjust the upper gold knob for a single knob compressor with auto makeup gain. For detailed editing, press the sidechain gold knob. The top LED will become a compression meter, and the bottom LED level will show the compressor input level. The bottom (reverb) knob will adjust the ratio in this mode, from 1:8 to infinity/brick wall. The compressor attack and release are editable on the affect entire attack and release buttons if desired.

- This feature can be turned ON/OFF in the Runtime Settings (Community Features) Menu (accessed by pressing "SHIFT" + "SELECT").

- Follow up PR's:
- ([#200]) Fixed master compressor. The masterVolumeAdjustment value is now considered in the process. With this change, threshold value are now displayed correctly. This modification affects songs that had saved master compressor settings.
- ([#220]) Fixed a bug in the song view that, when the "SIDECHAIN" knob was turned while holding down a clip pad, the "SIDECHAIN" value and the Master Compressor Threshold would change at the same time.

#### 4.1.2 - Change Row Colour

Expand Down Expand Up @@ -357,7 +352,7 @@ This list includes all preprocessor switches that can alter firmware behaviour a
[#122]: https://github.com/SynthstromAudible/DelugeFirmware/pull/122
[#125]: https://github.com/SynthstromAudible/DelugeFirmware/pull/125
[#129]: https://github.com/SynthstromAudible/DelugeFirmware/pull/129
[#137]: https://github.com/SynthstromAudible/DelugeFirmware/pull/137
[#630]: https://github.com/SynthstromAudible/DelugeFirmware/pull/630
[#138]: https://github.com/SynthstromAudible/DelugeFirmware/pull/138
[#141]: https://github.com/SynthstromAudible/DelugeFirmware/pull/141
[#157]: https://github.com/SynthstromAudible/DelugeFirmware/pull/157
Expand Down
1 change: 1 addition & 0 deletions src/definitions_cxx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ enum class EnvelopeStage : uint8_t {
SUSTAIN,
RELEASE,
FAST_RELEASE,
HOLD,
OFF,
};
constexpr int32_t kNumEnvelopeStages = util::to_underlying(EnvelopeStage::OFF) + 1;
Expand Down
62 changes: 48 additions & 14 deletions src/deluge/dsp/compressor/compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Compressor::Compressor() {
status = EnvelopeStage::OFF;
lastValue = 2147483647;
pos = 0;
follower = false;
attack = getParamFromUserValue(Param::Static::COMPRESSOR_ATTACK, 7);
release = getParamFromUserValue(Param::Static::COMPRESSOR_RELEASE, 28);
pendingHitStrength = 0;
Expand Down Expand Up @@ -80,11 +81,14 @@ void Compressor::registerHitRetrospectively(int32_t strength, uint32_t numSample
// If we're still in the release stage...
if (numSamplesSinceRelease < releaseStageLengthInSamples) {
pos = numSamplesSinceRelease * alteredRelease;
envelopeHeight = ONE_Q31 - envelopeOffset;
envelopeOffset = ONE_Q31;
status = EnvelopeStage::RELEASE;
}

// Or if we're past the release stage...
else {
envelopeOffset = ONE_Q31;
status = EnvelopeStage::OFF;
}
}
Expand Down Expand Up @@ -124,35 +128,65 @@ int32_t Compressor::getActualReleaseRate() {
int32_t Compressor::render(uint16_t numSamples, int32_t shapeValue) {

// Initial hit detected...
if (pendingHitStrength != 0) {
if (pendingHitStrength != 0 || follower) {
int32_t newOffset = ONE_Q31 - pendingHitStrength;

pendingHitStrength = 0;

//envelope offset is the value we're attack/decaying to
// Only actually do anything if this hit is going to cause a bigger dip than we're already currently experiencing
if (newOffset < lastValue) {
envelopeOffset = newOffset;

// If attack is all the way down, jump directly to release stage
if (attack == attackRateTable[0] << 2) {
goto prepareForRelease;
envelopeHeight = ONE_Q31 - envelopeOffset;
envelopeOffset = ONE_Q31;
pos = 0;
status = EnvelopeStage::RELEASE;
}
else {
if (!follower || status == EnvelopeStage::HOLD) {
status = EnvelopeStage::ATTACK;
pos = 0;
}
else if (status != EnvelopeStage::ATTACK) {
status = EnvelopeStage::HOLD;
}

envelopeHeight = lastValue - envelopeOffset;
}
}
//or if we're working in follower mode, in which case we want to start releasing whenever the current hit strength is below the envelope level
else if (follower && newOffset > envelopeOffset) {
envelopeOffset = newOffset;
envelopeHeight = newOffset - lastValue;
if (status == EnvelopeStage::HOLD) {
pos = 0;
status = EnvelopeStage::RELEASE;
}
else if (status != EnvelopeStage::RELEASE) {
status = EnvelopeStage::HOLD;
}

status = EnvelopeStage::ATTACK;
envelopeHeight = lastValue - envelopeOffset;
pos = 0;
}
}

if (status == EnvelopeStage::ATTACK) {
pos += numSamples * getActualAttackRate();

if (pos >= 8388608) {
//if we're in follower mode then we just hold the value
if (!follower) {
envelopeHeight = ONE_Q31 - envelopeOffset;
envelopeOffset = ONE_Q31;
prepareForRelease:
pos = 0;
status = EnvelopeStage::RELEASE;
envelopeHeight = ONE_Q31 - envelopeOffset;
goto doRelease;
pos = 0;
status = EnvelopeStage::RELEASE;

goto doRelease;
}
else {
status = EnvelopeStage::HOLD;
goto doOff;
}
}
//lastValue = (multiply_32x32_rshift32(envelopeHeight, decayTable4[pos >> 13]) << 1) + envelopeOffset; // Goes down quickly at first. Bad
//lastValue = (multiply_32x32_rshift32(envelopeHeight, 2147483647 - (pos << 8)) << 1) + envelopeOffset; // Straight line
Expand Down Expand Up @@ -191,15 +225,15 @@ int32_t Compressor::render(uint16_t numSamples, int32_t shapeValue) {
preValue = straightness * (pos >> 8) + (getDecay8(8388608 - pos, 23) >> 16) * curvedness16;
}

lastValue = ONE_Q31 - envelopeHeight + (multiply_32x32_rshift32(preValue, envelopeHeight) << 1);
lastValue = envelopeOffset - envelopeHeight + (multiply_32x32_rshift32(preValue, envelopeHeight) << 1);

//lastValue = 2147483647 - (multiply_32x32_rshift32(decayTable8[pos >> 13], envelopeHeight) << 1); // Upside down exponential curve
//lastValue = 2147483647 - (((int64_t)((sineWave[((pos >> 14) + 256) & 1023] >> 1) + 1073741824) * (int64_t)envelopeHeight) >> 31); // Sine wave. Not great
//lastValue = (multiply_32x32_rshift32(pos * (pos >> 15), envelopeHeight) << 1); // Parabola. Doesn't "punch".
}
else { // Off
doOff:
lastValue = ONE_Q31;
lastValue = envelopeOffset;
}

return lastValue - ONE_Q31;
Expand Down
2 changes: 1 addition & 1 deletion src/deluge/dsp/compressor/compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Compressor {
public:
Compressor();
void cloneFrom(Compressor* other);

bool follower;
EnvelopeStage status;
uint32_t pos;
int32_t lastValue;
Expand Down
88 changes: 0 additions & 88 deletions src/deluge/dsp/master_compressor/chunkware_simplecomp.cpp

This file was deleted.

Loading
Loading