45 template <
typename Type>
47 Type minusInfinityDb = Type (defaultMinusInfinitydB))
49 return decibels > minusInfinityDb ? std::pow (Type (10.0), decibels * Type (0.05))
59 template <
typename Type>
61 Type minusInfinityDb = Type (defaultMinusInfinitydB))
63 return gain > Type() ? jmax (minusInfinityDb, static_cast<Type> (std::log10 (gain)) * Type (20.0))
75 template <
typename Type>
77 int decimalPlaces = 2,
78 Type minusInfinityDb = Type (defaultMinusInfinitydB),
79 bool shouldIncludeSuffix =
true,
85 if (decibels <= minusInfinityDb)
87 if (customMinusInfinityString.isEmpty())
90 s << customMinusInfinityString;
94 if (decibels >= Type())
97 if (decimalPlaces <= 0)
98 s << roundToInt (decibels);
100 s <<
String (decibels, decimalPlaces);
103 if (shouldIncludeSuffix)
111 enum { defaultMinusInfinitydB = -100 };
static Type decibelsToGain(Type decibels, Type minusInfinityDb=Type(defaultMinusInfinitydB))
Converts a dBFS value to its equivalent gain level.
A simple class for holding temporary references to a string literal or String.
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.
This class contains some helpful static methods for dealing with decibel values.
void preallocateBytes(size_t numBytesNeeded)
Increases the string's internally allocated storage.