Skip to content

Commit

Permalink
set better defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
m-m-adams committed Oct 22, 2023
1 parent 85fe37e commit 9103238
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
9 changes: 4 additions & 5 deletions src/deluge/dsp/master_compressor/master_compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ MasterCompressor::MasterCompressor() {
//compressor.setRatio(1.0 / ((float)ratio / 100.0));
shape = getParamFromUserValue(Param::Unpatched::COMPRESSOR_SHAPE, 1);
//an appropriate range is 0-50*one q 15
threshold = 15 * ONE_Q15;
threshold = ONE_Q31;
follower = true;
//this is about a 1:1 ratio
ratio = ONE_Q31 >> 3;
ratio = ONE_Q31 >> 1;
syncLevel = SyncLevel::SYNC_LEVEL_NONE;
currentVolume = 0;
//auto make up gain
Expand All @@ -40,10 +40,9 @@ MasterCompressor::MasterCompressor() {
void MasterCompressor::updateER() {
threshdb = 16 * (threshold / ONE_Q31f);
//14 is about the level of a single synth voice
er = std::clamp<float>((16 - threshdb) * (float(ratio) / ONE_Q31f), 0, 4);
er = std::clamp<float>((16 - threshdb) * (float(ratio) / ONE_Q31f), 0, 15);
}

//with floats baseline is 60-90us
void MasterCompressor::render(StereoSample* buffer, uint16_t numSamples) {
meanVolume = calc_rms(buffer, numSamples);

Expand Down Expand Up @@ -79,7 +78,7 @@ void MasterCompressor::render(StereoSample* buffer, uint16_t numSamples) {
} while (++thisSample != bufferEnd);
//for LEDs
//9 converts to dB, quadrupled for display range since a 30db reduction is basically killing the signal
gr = -reduction * 9 * 4;
gr = std::clamp<int32_t>(-reduction * 9 * 4, 0, 127);
}

//output range is 0-21 (2^31)
Expand Down
2 changes: 1 addition & 1 deletion src/deluge/model/global_effectable/global_effectable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ ActionResult GlobalEffectable::modEncoderActionForNonExistentParam(int32_t offse
int current = AudioEngine::mastercompressor.threshold >> 24;
current -= offset;
current = std::clamp(current, 1, 128);
indicator_leds::setKnobIndicatorLevel(1, std::max(0, 128 - 3 * (current - 2)));
indicator_leds::setKnobIndicatorLevel(1, std::max(0, 128 - current));
AudioEngine::mastercompressor.threshold = lshiftAndSaturate<24>(current);
AudioEngine::mastercompressor.updateER();
return ActionResult::DEALT_WITH;
Expand Down
14 changes: 6 additions & 8 deletions src/deluge/model/song/song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,10 @@ Song::Song() : backedUpParamManagers(sizeof(BackedUpParamManager)) {
reverbCompressorShape = -601295438;
reverbCompressorSync = SYNC_LEVEL_8TH;

masterCompressorAttack = 7;
masterCompressorRelease = 10;
masterCompressorThresh = 10;
masterCompressorRatio = 10;
masterCompressorMakeup = 0;
masterCompressorWet = 50;
masterCompressorAttack = attackRateTable[2] << 2;
masterCompressorRelease = releaseRateTable[5] << 2;
masterCompressorThresh = ONE_Q31;
masterCompressorRatio = ONE_Q31 >> 1;
AudioEngine::mastercompressor.gr = 0.0;

dirPath.set("SONGS");
Expand Down Expand Up @@ -2672,7 +2670,7 @@ int32_t Song::getCurrentPresetScale() {
// If we're here, must be this one!
return p;

notThisOne : {}
notThisOne: {}
}

return 255;
Expand Down Expand Up @@ -4561,7 +4559,7 @@ Instrument* Song::changeInstrumentType(Instrument* oldInstrument, InstrumentType
return NULL;
}

gotAnInstrument : {}
gotAnInstrument: {}
}

// Synth or Kit
Expand Down
2 changes: 0 additions & 2 deletions src/deluge/model/song/song.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ class Song final : public TimelineCounter {
int32_t masterCompressorRelease;
int32_t masterCompressorThresh;
int32_t masterCompressorRatio;
int32_t masterCompressorMakeup;
int32_t masterCompressorWet;

private:
bool fillModeActive;
Expand Down
4 changes: 2 additions & 2 deletions src/deluge/processing/engines/audio_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ void routine() {
}
logAction("mastercomp start");
mastercompressor.render(renderingBuffer, numSamples);
masterVolumeAdjustmentL <<= 3;
masterVolumeAdjustmentR <<= 3;
masterVolumeAdjustmentL <<= 2;
masterVolumeAdjustmentR <<= 2;
logAction("mastercomp end");
metronome.render(renderingBuffer, numSamples);

Expand Down

0 comments on commit 9103238

Please sign in to comment.