ReplayGain: added a dedicated preamp gain for tracks that do not have RG info. ref #38
This commit is contained in:
@@ -169,7 +169,8 @@
|
||||
<message id="Lms.Settings.replaygain-mode.auto">Auto</message>
|
||||
<message id="Lms.Settings.replaygain-mode.track">Track</message>
|
||||
<message id="Lms.Settings.replaygain-mode.release">Album</message>
|
||||
<message id="Lms.Settings.replaygain-preamp">Replay gain preAmp</message>
|
||||
<message id="Lms.Settings.replaygain-preamp">ReplayGain preamp</message>
|
||||
<message id="Lms.Settings.replaygain-preamp-no-rg-info">ReplayGain preamp (if no info)</message>
|
||||
<message id="Lms.Settings.subsonic-artist-list-mode">Artist list mode</message>
|
||||
<message id="Lms.Settings.subsonic-artist-list-mode.all-artists">All artists</message>
|
||||
<message id="Lms.Settings.subsonic-artist-list-mode.release-artists">Album artists</message>
|
||||
|
||||
+13
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
<message id="Lms.Settings.template">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="col-lg-8">
|
||||
<legend>${tr:Lms.Settings.appearance}</legend>
|
||||
<div class="form-horizontal">
|
||||
<div class="form-group">
|
||||
@@ -74,6 +74,18 @@
|
||||
${replaygain-preamp-info class="help-block"}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-3 control-label" for="${id:replaygain-preamp-no-rg-info}">
|
||||
${tr:Lms.Settings.replaygain-preamp-no-rg-info}
|
||||
</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="input-group">
|
||||
${replaygain-preamp-no-rg-info}
|
||||
<span class="input-group-addon">dB</span>
|
||||
</div>
|
||||
${replaygain-preamp-no-rg-info-info class="help-block"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
${<if-has-subsonic-api>}
|
||||
<legend>${tr:Lms.Settings.subsonic-api}</legend>
|
||||
|
||||
@@ -59,6 +59,7 @@ static std::string settingsToJSString(const MediaPlayer::Settings& settings)
|
||||
Json::Object replayGain;
|
||||
replayGain["mode"] = static_cast<int>(settings.replayGain.mode);
|
||||
replayGain["preAmpGain"] = settings.replayGain.preAmpGain;
|
||||
replayGain["preAmpGainIfNoInfo"] = settings.replayGain.preAmpGainIfNoInfo;
|
||||
res["replayGain"] = std::move(replayGain);
|
||||
}
|
||||
|
||||
@@ -180,6 +181,7 @@ static MediaPlayer::Settings settingsfromJSString(const std::string& strSettings
|
||||
const Json::Object replayGain {replayGainValue};
|
||||
settings.replayGain.mode = replayGainModeFromString(replayGain.get("mode").toString().orIfNull("")).value_or(Settings::ReplayGain::defaultMode);
|
||||
settings.replayGain.preAmpGain = replayGainPreAmpGainFromString(replayGain.get("preAmpGain").toString().orIfNull("")).value_or(Settings::ReplayGain::defaultPreAmpGain);
|
||||
settings.replayGain.preAmpGainIfNoInfo = replayGainPreAmpGainFromString(replayGain.get("preAmpGainIfNoInfo").toString().orIfNull("")).value_or(Settings::ReplayGain::defaultPreAmpGain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,9 @@ class MediaPlayer : public Wt::WTemplate
|
||||
static inline constexpr Gain minPreAmpGain {-15};
|
||||
static inline constexpr Gain maxPreAmpGain {15};
|
||||
|
||||
Mode mode;
|
||||
Gain preAmpGain;
|
||||
Mode mode {defaultMode};
|
||||
Gain preAmpGain {defaultPreAmpGain};
|
||||
Gain preAmpGainIfNoInfo {defaultPreAmpGain};
|
||||
};
|
||||
|
||||
Transcode transcode;
|
||||
|
||||
@@ -453,7 +453,7 @@ PlayQueue::getReplayGain(std::size_t pos, const Database::Track::pointer& track)
|
||||
switch (settings->replayGain.mode)
|
||||
{
|
||||
case MediaPlayer::Settings::ReplayGain::Mode::None:
|
||||
break;
|
||||
return std::nullopt;
|
||||
|
||||
case MediaPlayer::Settings::ReplayGain::Mode::Track:
|
||||
gain = track->getTrackReplayGain();
|
||||
@@ -461,6 +461,8 @@ PlayQueue::getReplayGain(std::size_t pos, const Database::Track::pointer& track)
|
||||
|
||||
case MediaPlayer::Settings::ReplayGain::Mode::Release:
|
||||
gain = track->getReleaseReplayGain();
|
||||
if (!gain)
|
||||
gain = track->getTrackReplayGain();
|
||||
break;
|
||||
|
||||
case MediaPlayer::Settings::ReplayGain::Mode::Auto:
|
||||
@@ -476,6 +478,8 @@ PlayQueue::getReplayGain(std::size_t pos, const Database::Track::pointer& track)
|
||||
(nextTrack && nextTrack->getRelease() && nextTrack->getRelease() == track->getRelease()))
|
||||
{
|
||||
gain = track->getReleaseReplayGain();
|
||||
if (!gain)
|
||||
gain = track->getTrackReplayGain();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -488,7 +492,7 @@ PlayQueue::getReplayGain(std::size_t pos, const Database::Track::pointer& track)
|
||||
if (gain)
|
||||
return *gain + settings->replayGain.preAmpGain;
|
||||
|
||||
return std::nullopt;
|
||||
return settings->replayGain.preAmpGainIfNoInfo;
|
||||
}
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -55,6 +55,7 @@ class SettingsModel : public Wt::WFormModel
|
||||
static inline const Field TranscodeBitrateField {"transcode-bitrate"};
|
||||
static inline const Field ReplayGainModeField {"replaygain-mode"};
|
||||
static inline const Field ReplayGainPreAmpGainField {"replaygain-preamp"};
|
||||
static inline const Field ReplayGainPreAmpGainIfNoInfoField {"replaygain-preamp-no-rg-info"};
|
||||
static inline const Field SubsonicArtistListModeField {"subsonic-artist-list-mode"};
|
||||
static inline const Field SubsonicTranscodeEnableField {"subsonic-transcode-enable"};
|
||||
static inline const Field SubsonicTranscodeFormatField {"subsonic-transcode-format"};
|
||||
@@ -77,6 +78,7 @@ class SettingsModel : public Wt::WFormModel
|
||||
addField(TranscodeFormatField);
|
||||
addField(ReplayGainModeField);
|
||||
addField(ReplayGainPreAmpGainField);
|
||||
addField(ReplayGainPreAmpGainIfNoInfoField);
|
||||
addField(SubsonicTranscodeEnableField);
|
||||
addField(SubsonicTranscodeBitrateField);
|
||||
addField(SubsonicTranscodeFormatField);
|
||||
@@ -91,11 +93,16 @@ class SettingsModel : public Wt::WFormModel
|
||||
setValidator(TranscodeBitrateField, createMandatoryValidator());
|
||||
setValidator(TranscodeFormatField, createMandatoryValidator());
|
||||
setValidator(ReplayGainModeField, createMandatoryValidator());
|
||||
|
||||
auto createPreAmpValidator = []
|
||||
{
|
||||
auto preampGainValidator {std::make_unique<Wt::WDoubleValidator>()};
|
||||
preampGainValidator->setRange(MediaPlayer::Settings::ReplayGain::minPreAmpGain, MediaPlayer::Settings::ReplayGain::maxPreAmpGain);
|
||||
setValidator(ReplayGainPreAmpGainField, std::move(preampGainValidator));
|
||||
}
|
||||
return preampGainValidator;
|
||||
};
|
||||
|
||||
setValidator(ReplayGainPreAmpGainField, createPreAmpValidator());
|
||||
setValidator(ReplayGainPreAmpGainIfNoInfoField, createPreAmpValidator());
|
||||
setValidator(SubsonicTranscodeBitrateField, createMandatoryValidator());
|
||||
setValidator(SubsonicTranscodeFormatField, createMandatoryValidator());
|
||||
|
||||
@@ -147,6 +154,7 @@ class SettingsModel : public Wt::WFormModel
|
||||
settings.replayGain.mode = _replayGainModeModel->getValue(*replayGainModeRow);
|
||||
|
||||
settings.replayGain.preAmpGain = Wt::asNumber(value(ReplayGainPreAmpGainField));
|
||||
settings.replayGain.preAmpGainIfNoInfo = Wt::asNumber(value(ReplayGainPreAmpGainIfNoInfoField));
|
||||
|
||||
LmsApp->getMediaPlayer()->setSettings(settings);
|
||||
}
|
||||
@@ -202,6 +210,7 @@ class SettingsModel : public Wt::WFormModel
|
||||
setValue(ReplayGainModeField, _replayGainModeModel->getString(*replayGainModeRow));
|
||||
|
||||
setValue(ReplayGainPreAmpGainField, settings.replayGain.preAmpGain);
|
||||
setValue(ReplayGainPreAmpGainIfNoInfoField, settings.replayGain.preAmpGainIfNoInfo);
|
||||
}
|
||||
|
||||
setValue(SubsonicTranscodeEnableField, LmsApp->getUser()->getSubsonicTranscodeEnable());
|
||||
@@ -434,15 +443,24 @@ SettingsView::refreshView()
|
||||
replayGainPreampGain->setRange(MediaPlayer::Settings::ReplayGain::minPreAmpGain, MediaPlayer::Settings::ReplayGain::maxPreAmpGain);
|
||||
t->setFormWidget(SettingsModel::ReplayGainPreAmpGainField, std::move(replayGainPreampGain));
|
||||
|
||||
// Replay gain preampGain if no info
|
||||
auto replayGainPreampGainIfNoInfo {std::make_unique<Wt::WDoubleSpinBox>()};
|
||||
replayGainPreampGainIfNoInfo->setRange(MediaPlayer::Settings::ReplayGain::minPreAmpGain, MediaPlayer::Settings::ReplayGain::maxPreAmpGain);
|
||||
t->setFormWidget(SettingsModel::ReplayGainPreAmpGainIfNoInfoField, std::move(replayGainPreampGainIfNoInfo));
|
||||
|
||||
replayGainModeRaw->activated().connect([=](int row)
|
||||
{
|
||||
const bool enable {model->getReplayGainModeModel()->getValue(row) != MediaPlayer::Settings::ReplayGain::Mode::None};
|
||||
model->setReadOnly(SettingsModel::SettingsModel::ReplayGainPreAmpGainField, !enable);
|
||||
model->setReadOnly(SettingsModel::SettingsModel::ReplayGainPreAmpGainIfNoInfoField, !enable);
|
||||
t->updateModel(model.get());
|
||||
t->updateView(model.get());
|
||||
});
|
||||
if (LmsApp->getMediaPlayer()->getSettings()->replayGain.mode == MediaPlayer::Settings::ReplayGain::Mode::None)
|
||||
{
|
||||
model->setReadOnly(SettingsModel::SettingsModel::ReplayGainPreAmpGainField, true);
|
||||
model->setReadOnly(SettingsModel::SettingsModel::ReplayGainPreAmpGainIfNoInfoField, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Subsonic
|
||||
|
||||
Reference in New Issue
Block a user