Skip to content

Commit

Permalink
Merge pull request #11865 from DaveTBlake/ReplaygainFixLeia
Browse files Browse the repository at this point in the history
paplayer: restore option for replaygain reduction as clipping protection
  • Loading branch information
MartijnKaijser committed Apr 15, 2017
2 parents 7c0488a + cdeb0d4 commit bcbbc14
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
11 changes: 9 additions & 2 deletions addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -2911,7 +2911,10 @@ msgctxt "#642"
msgid "Files without ReplayGain information"
msgstr ""

#empty string with id 643
#: system/settings/settings.xml
msgctxt "#643"
msgid "Avoid clipping protection on ReplayGained files"
msgstr ""

#: system/settings/settings.xml
msgctxt "#644"
Expand Down Expand Up @@ -18183,7 +18186,11 @@ msgctxt "#36269"
msgid "Reference volume (PreAmp level) to use for files without encoded ReplayGain information. Default is 89dB as per standard. Change with caution."
msgstr ""

#empty string with id 36270
#. Description of setting with label #643 "Avoid clipping protection on ReplayGained files"
#: system/settings/settings.xml
msgctxt "#36270"
msgid "Play file at lower volume, if necessary, to avoid audio limiting clipping protection. Otherwise clipping protection will be provided by the audioengine in those parts that need it."
msgstr ""

#. Description of setting with label #13314 "Crossfade between songs"
#: system/settings/settings.xml
Expand Down
8 changes: 8 additions & 0 deletions system/settings/settings.xml
Expand Up @@ -471,6 +471,14 @@
<dependency type="enable" setting="musicplayer.replaygaintype" operator="!is">0</dependency>
</dependencies>
</setting>
<setting id="musicplayer.replaygainavoidclipping" type="boolean" parent="musicplayer.replaygaintype" label="643" help="36270">
<level>3</level>
<default>false</default>
<control type="toggle" />
<dependencies>
<dependency type="enable" setting="musicplayer.replaygaintype" operator="!is">0</dependency>
</dependencies>
</setting>
</group>
</category>
<category id="discs" label="14087" help="36193">
Expand Down
3 changes: 3 additions & 0 deletions xbmc/Application.cpp
Expand Up @@ -649,6 +649,7 @@ bool CApplication::Create()
m_replayGainSettings.iType = m_ServiceManager->GetSettings().GetInt(CSettings::SETTING_MUSICPLAYER_REPLAYGAINTYPE);
m_replayGainSettings.iPreAmp = m_ServiceManager->GetSettings().GetInt(CSettings::SETTING_MUSICPLAYER_REPLAYGAINPREAMP);
m_replayGainSettings.iNoGainPreAmp = m_ServiceManager->GetSettings().GetInt(CSettings::SETTING_MUSICPLAYER_REPLAYGAINNOGAINPREAMP);
m_replayGainSettings.bAvoidClipping = m_ServiceManager->GetSettings().GetBool(CSettings::SETTING_MUSICPLAYER_REPLAYGAINAVOIDCLIPPING);

// Create the Mouse, Keyboard and Remote
CInputManager::GetInstance().InitializeInputs();
Expand Down Expand Up @@ -1429,6 +1430,8 @@ void CApplication::OnSettingChanged(const CSetting *setting)
m_replayGainSettings.iPreAmp = ((CSettingInt*)setting)->GetValue();
else if (StringUtils::EqualsNoCase(settingId, CSettings::SETTING_MUSICPLAYER_REPLAYGAINNOGAINPREAMP))
m_replayGainSettings.iNoGainPreAmp = ((CSettingInt*)setting)->GetValue();
else if (StringUtils::EqualsNoCase(settingId, CSettings::SETTING_MUSICPLAYER_REPLAYGAINAVOIDCLIPPING))
m_replayGainSettings.bAvoidClipping = ((CSettingBool*)setting)->GetValue();
}

void CApplication::OnSettingAction(const CSetting *setting)
Expand Down
1 change: 1 addition & 0 deletions xbmc/Application.h
Expand Up @@ -108,6 +108,7 @@ struct ReplayGainSettings
int iPreAmp;
int iNoGainPreAmp;
int iType;
bool bAvoidClipping;
};

class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMsgTargetCallback,
Expand Down
5 changes: 4 additions & 1 deletion xbmc/cores/paplayer/PAPlayer.cpp
Expand Up @@ -499,8 +499,11 @@ inline bool PAPlayer::PrepareStream(StreamInfo *si)
if (peak * gain <= 1.0)
// No clipping protection needed
si->m_stream->SetReplayGain(gain);
else if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MUSICPLAYER_REPLAYGAINAVOIDCLIPPING))
// Normalise volume reducing replaygain to avoid needing clipping protection, plays file at lower level
si->m_stream->SetReplayGain(1.0f / fabs(peak));
else
// Clipping protecton provided as audio limiting
// Clipping protection (when enabled in AE) by audio limiting, applied just where needed
si->m_stream->SetAmplification(gain);

/* if its not the first stream and crossfade is not enabled */
Expand Down
2 changes: 2 additions & 0 deletions xbmc/settings/Settings.cpp
Expand Up @@ -279,6 +279,7 @@ const std::string CSettings::SETTING_MUSICPLAYER_SEEKDELAY = "musicplayer.seekde
const std::string CSettings::SETTING_MUSICPLAYER_REPLAYGAINTYPE = "musicplayer.replaygaintype";
const std::string CSettings::SETTING_MUSICPLAYER_REPLAYGAINPREAMP = "musicplayer.replaygainpreamp";
const std::string CSettings::SETTING_MUSICPLAYER_REPLAYGAINNOGAINPREAMP = "musicplayer.replaygainnogainpreamp";
const std::string CSettings::SETTING_MUSICPLAYER_REPLAYGAINAVOIDCLIPPING = "musicplayer.replaygainavoidclipping";
const std::string CSettings::SETTING_MUSICPLAYER_CROSSFADE = "musicplayer.crossfade";
const std::string CSettings::SETTING_MUSICPLAYER_CROSSFADEALBUMTRACKS = "musicplayer.crossfadealbumtracks";
const std::string CSettings::SETTING_MUSICPLAYER_VISUALISATION = "musicplayer.visualisation";
Expand Down Expand Up @@ -1091,6 +1092,7 @@ void CSettings::InitializeISettingCallbacks()
settingSet.insert(CSettings::SETTING_MUSICPLAYER_REPLAYGAINPREAMP);
settingSet.insert(CSettings::SETTING_MUSICPLAYER_REPLAYGAINNOGAINPREAMP);
settingSet.insert(CSettings::SETTING_MUSICPLAYER_REPLAYGAINTYPE);
settingSet.insert(CSettings::SETTING_MUSICPLAYER_REPLAYGAINAVOIDCLIPPING);
settingSet.insert(CSettings::SETTING_SCRAPERS_MUSICVIDEOSDEFAULT);
settingSet.insert(CSettings::SETTING_SCREENSAVER_MODE);
settingSet.insert(CSettings::SETTING_SCREENSAVER_PREVIEW);
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/Settings.h
Expand Up @@ -233,6 +233,7 @@ class CSettings : public CSettingCreator, public CSettingControlCreator
static const std::string SETTING_MUSICPLAYER_REPLAYGAINTYPE;
static const std::string SETTING_MUSICPLAYER_REPLAYGAINPREAMP;
static const std::string SETTING_MUSICPLAYER_REPLAYGAINNOGAINPREAMP;
static const std::string SETTING_MUSICPLAYER_REPLAYGAINAVOIDCLIPPING;
static const std::string SETTING_MUSICPLAYER_CROSSFADE;
static const std::string SETTING_MUSICPLAYER_CROSSFADEALBUMTRACKS;
static const std::string SETTING_MUSICPLAYER_VISUALISATION;
Expand Down

0 comments on commit bcbbc14

Please sign in to comment.