41 template <
typename Type>
43 Type minusInfinityDb = Type (defaultMinusInfinitydB))
45 return decibels > minusInfinityDb ?
std::pow (Type (10.0), decibels * Type (0.05))
55 template <
typename Type>
57 Type minusInfinityDb = Type (defaultMinusInfinitydB))
59 return gain > Type() ?
jmax (minusInfinityDb,
static_cast<Type
> (
std::log10 (gain)) * Type (20.0))
67 template <
typename Type>
72 jassert (lowerBoundDb < (Type) 0.0);
85 template <
typename Type>
87 int decimalPlaces = 2,
88 Type minusInfinityDb = Type (defaultMinusInfinitydB),
89 bool shouldIncludeSuffix =
true,
95 if (decibels <= minusInfinityDb)
97 if (customMinusInfinityString.isEmpty())
100 s << customMinusInfinityString;
104 if (decibels >= Type())
107 if (decimalPlaces <= 0)
110 s << String (decibels, decimalPlaces);
113 if (shouldIncludeSuffix)
121 enum { defaultMinusInfinitydB = -100 };
This class contains some helpful static methods for dealing with decibel values.
static Type gainWithLowerBound(Type gain, Type lowerBoundDb)
Restricts a gain value based on a lower bound specified in dBFS.
static Type decibelsToGain(Type decibels, Type minusInfinityDb=Type(defaultMinusInfinitydB))
Converts a dBFS value to its equivalent gain level.
static Type gainToDecibels(Type gain, Type minusInfinityDb=Type(defaultMinusInfinitydB))
Converts a gain level into a dBFS value.
static String toString(Type decibels, int decimalPlaces=2, Type minusInfinityDb=Type(defaultMinusInfinitydB), bool shouldIncludeSuffix=true, StringRef customMinusInfinityString={})
Converts a decibel reading to a string.
A simple class for holding temporary references to a string literal or String.
void preallocateBytes(size_t numBytesNeeded)
Increases the string's internally allocated storage.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.