Song: add pretty-printers for EBU R 128 Integrated Loudness and Loudness Range fields
They end up being used in a quite a number of places later on, it makes sense to have them in a common place. Integrated Loudness (LUFS) is *usually* negative, so we really want to always print a sign. But Loudness Range is non-negative. I think it makes sense to print one or at most two decimal places for these.
This commit is contained in:
parent
459c4c5d86
commit
e589486907
|
@ -685,6 +685,26 @@ QString Song::SampleRateBitDepthToText() const {
|
|||
|
||||
}
|
||||
|
||||
QString Song::Ebur128LoudnessLUFSToText(const std::optional<double> &v) {
|
||||
|
||||
if (!v) return QObject::tr("Unknown");
|
||||
|
||||
return QString::asprintf("%+.2f ", *v) + QObject::tr("LUFS");
|
||||
}
|
||||
QString Song::Ebur128LoudnessLUFSToText() const {
|
||||
return Ebur128LoudnessLUFSToText(d->ebur128_integrated_loudness_lufs_);
|
||||
}
|
||||
|
||||
QString Song::Ebur128LoudnessRangeLUToText(const std::optional<double> &v) {
|
||||
|
||||
if (!v) return QObject::tr("Unknown");
|
||||
|
||||
return QString::asprintf("%.2f ", *v) + QObject::tr("LU");
|
||||
}
|
||||
QString Song::Ebur128LoudnessRangeLUToText() const {
|
||||
return Ebur128LoudnessRangeLUToText(d->ebur128_loudness_range_lu_);
|
||||
}
|
||||
|
||||
QString Song::PrettyRating() const {
|
||||
|
||||
float rating = d->rating_;
|
||||
|
|
|
@ -225,6 +225,12 @@ class Song {
|
|||
|
||||
const QUrl &stream_url() const;
|
||||
|
||||
static QString Ebur128LoudnessLUFSToText(const std::optional<double> &v);
|
||||
QString Ebur128LoudnessLUFSToText() const;
|
||||
|
||||
static QString Ebur128LoudnessRangeLUToText(const std::optional<double> &v);
|
||||
QString Ebur128LoudnessRangeLUToText() const;
|
||||
|
||||
// Setters
|
||||
void set_id(const int id);
|
||||
void set_valid(const bool v);
|
||||
|
|
Loading…
Reference in New Issue