diff --git a/modules/juce_audio_basics/effects/juce_Decibels.h b/modules/juce_audio_basics/effects/juce_Decibels.h index 4fc2d2fdbf..11da7b1cde 100644 --- a/modules/juce_audio_basics/effects/juce_Decibels.h +++ b/modules/juce_audio_basics/effects/juce_Decibels.h @@ -59,33 +59,41 @@ public: } //============================================================================== - /** Converts a decibel reading to a string, with the 'dB' suffix. - If the decibel value is lower than minusInfinityDb, the return value will - be "-INF dB". + /** Converts a decibel reading to a string. + + By default the returned string will have the 'dB' suffix added, but this can be removed by + setting the shouldIncludeSuffix argument to false. If a customMinusInfinityString argument + is provided this will be returned if the value is lower than minusInfinityDb, otherwise + the return value will be "-INF". */ template static String toString (const Type decibels, const int decimalPlaces = 2, - const Type minusInfinityDb = (Type) defaultMinusInfinitydB) + const Type minusInfinityDb = (Type) defaultMinusInfinitydB, + bool shouldIncludeSuffix = true, + StringRef customMinusInfinityString = {}) { String s; if (decibels <= minusInfinityDb) { - s = "-INF dB"; + s = customMinusInfinityString.isEmpty() ? "-INF" + : customMinusInfinityString; } else { if (decibels >= Type()) s << '+'; - s << String (decibels, decimalPlaces) << " dB"; + s += String (decibels, decimalPlaces); } + if (shouldIncludeSuffix) + s += " dB"; + return s; } - private: //============================================================================== enum