From 35ad102a6a7ba7ed3243ee0546f5ec706dbb3913 Mon Sep 17 00:00:00 2001 From: paulfd Date: Wed, 28 Aug 2019 17:22:45 +0200 Subject: [PATCH] Apply a small base gain to avoid clipping --- sources/Defaults.h | 2 +- sources/StereoSpan.h | 6 ++++++ sources/Voice.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sources/Defaults.h b/sources/Defaults.h index b7208ba0..45de4c8b 100644 --- a/sources/Defaults.h +++ b/sources/Defaults.h @@ -59,7 +59,7 @@ namespace Default inline constexpr Range ccTriggerValueRange{ 0, 127 }; // Performance parameters: amplifier - inline constexpr float volume { 0.0 }; + inline constexpr float volume { -3.0 }; inline constexpr Range volumeRange { -144.0, 6.0 }; inline constexpr Range volumeCCRange { -144.0, 6.0 }; inline constexpr float amplitude { 100.0 }; diff --git a/sources/StereoSpan.h b/sources/StereoSpan.h index b3fa3550..561c4320 100644 --- a/sources/StereoSpan.h +++ b/sources/StereoSpan.h @@ -88,6 +88,12 @@ public: ::applyGain(gain, rightBuffer); } + void applyGain(Type gain) noexcept + { + ::applyGain(gain, leftBuffer); + ::applyGain(gain, rightBuffer); + } + void readInterleaved(absl::Span input) noexcept { ASSERT(input.size() <= static_cast(numChannels * numFrames)); diff --git a/sources/Voice.h b/sources/Voice.h index e11ae666..c2dce465 100644 --- a/sources/Voice.h +++ b/sources/Voice.h @@ -135,6 +135,8 @@ public: egEnvelope.getBlock(tempSpan1.first(numSamples)); buffer.applyGain(tempSpan1); + buffer.applyGain(baseGain); + if (!egEnvelope.isSmoothing()) reset(); }