Skip to content

Commit

Permalink
Remove unit from Compressor ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Feb 18, 2024
1 parent 6f63d2e commit 33d9de7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions lib/grit/audio/dynamic/dynamic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ struct Dynamic
struct Parameter
{
Decibels<Float> threshold{0.0};
Decibels<Float> ratio{1.0};
Decibels<Float> knee{0.0};
Float ratio{1.0};

Milliseconds<Float> attack{50};
Milliseconds<Float> release{50};
};
Expand All @@ -22,7 +23,7 @@ struct Dynamic

auto setParameter(Parameter param) -> void
{
_gainComputer.setParameter({param.threshold, param.ratio, param.knee});
_gainComputer.setParameter({param.threshold, param.knee, param.ratio});
_ballistics.setParameter({param.attack, param.release});
}

Expand Down
8 changes: 4 additions & 4 deletions lib/grit/audio/dynamic/gain_computer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ template<etl::floating_point Float>
struct GainComputerParameter
{
Decibels<Float> threshold{0.0};
Decibels<Float> ratio{1.0};
Decibels<Float> knee{0.0};
Float ratio{1.0};
};

/// \ingroup grit-audio-dynamic
Expand All @@ -30,13 +30,13 @@ struct HardKneeGainComputer
[[nodiscard]] auto operator()(Float xg) -> Float
{
auto const T = _threshold.value();
auto const R = _ratio.value();
auto const R = _ratio;
return xg < T ? xg : T + (xg - T) / R;
}

private:
Decibels<Float> _threshold{0};
Decibels<Float> _ratio{0};
Float _ratio{1};
};

/// \ingroup grit-audio-dynamic
Expand All @@ -52,8 +52,8 @@ struct SoftKneeGainComputer
[[nodiscard]] auto operator()(Float x) -> Float
{
auto const T = _parameter.threshold.value();
auto const R = _parameter.ratio.value();
auto const W = _parameter.knee.value();
auto const R = _parameter.ratio;

if (W < Float(2) * T - Float(2) * x) {
return x;
Expand Down
2 changes: 1 addition & 1 deletion lib/grit/eurorack/hades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ auto Hades::Channel::setParameter(Parameter const& parameter) -> void

_compressor.setParameter({
.threshold = Decibels<float>{remap(parameter.compressor, -6.0F, -12.0F)},
.ratio = Decibels<float>{remap(parameter.compressor, +1.0F, +8.0F)},
.knee = Decibels<float>{2.0F},
.ratio = remap(parameter.compressor, +1.0F, +8.0F),
.attack = attack,
.release = release,
});
Expand Down

0 comments on commit 33d9de7

Please sign in to comment.