Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
77c1f548
Commit
77c1f548
authored
Nov 25, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReplayGainConfig: add struct ReplayGainConfig, move globals to ReplayGainGlobal.cxx
parent
dc5984d0
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
69 additions
and
40 deletions
+69
-40
Makefile.am
Makefile.am
+4
-3
Main.cxx
src/Main.cxx
+1
-1
ReplayGainConfig.hxx
src/ReplayGainConfig.hxx
+8
-7
ReplayGainGlobal.cxx
src/ReplayGainGlobal.cxx
+6
-10
ReplayGainGlobal.hxx
src/ReplayGainGlobal.hxx
+35
-0
ReplayGainInfo.cxx
src/ReplayGainInfo.cxx
+5
-5
ReplayGainInfo.hxx
src/ReplayGainInfo.hxx
+3
-2
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+1
-1
Bridge.cxx
src/decoder/Bridge.cxx
+2
-4
ReplayGainFilterPlugin.cxx
src/filter/plugins/ReplayGainFilterPlugin.cxx
+2
-4
FakeReplayGainGlobal.cxx
test/FakeReplayGainGlobal.cxx
+2
-3
No files found.
Makefile.am
View file @
77c1f548
...
...
@@ -166,7 +166,7 @@ libmpd_a_SOURCES = \
src/queue/PlaylistState.cxx src/queue/PlaylistState.hxx
\
src/queue/Listener.hxx
\
src/PluginUnavailable.hxx
\
src/ReplayGain
Config.cxx src/ReplayGainConfig
.hxx
\
src/ReplayGain
Global.cxx src/ReplayGainGlobal
.hxx
\
src/DetachedSong.cxx src/DetachedSong.hxx
\
src/LocateUri.cxx src/LocateUri.hxx
\
src/SongUpdate.cxx
\
...
...
@@ -853,6 +853,7 @@ libbasic_a_SOURCES = \
src/CheckAudioFormat.cxx src/CheckAudioFormat.hxx
\
src/AudioFormat.cxx src/AudioFormat.hxx
\
src/AudioParser.cxx src/AudioParser.hxx
\
src/ReplayGainConfig.hxx
\
src/ReplayGainMode.cxx src/ReplayGainMode.hxx
\
src/ReplayGainInfo.cxx src/ReplayGainInfo.hxx
...
...
@@ -1978,7 +1979,7 @@ test_run_filter_LDADD = \
libsystem.a
\
libutil.a
test_run_filter_SOURCES
=
test
/run_filter.cxx
\
test
/FakeReplayGain
Config
.cxx
\
test
/FakeReplayGain
Global
.cxx
\
src/Log.cxx src/LogBackend.cxx
\
src/filter/FilterPlugin.cxx src/filter/FilterRegistry.cxx
...
...
@@ -2073,7 +2074,7 @@ test_run_output_LDADD = $(MPD_LIBS) \
libthread.a
\
libutil.a
test_run_output_SOURCES
=
test
/run_output.cxx
\
test
/FakeReplayGain
Config
.cxx
\
test
/FakeReplayGain
Global
.cxx
\
test
/ScopeIOThread.hxx
\
src/Log.cxx src/LogBackend.cxx
\
src/IOThread.cxx
\
...
...
src/Main.cxx
View file @
77c1f548
...
...
@@ -33,7 +33,7 @@
#include "command/AllCommands.hxx"
#include "Partition.hxx"
#include "tag/TagConfig.hxx"
#include "ReplayGain
Config
.hxx"
#include "ReplayGain
Global
.hxx"
#include "Idle.hxx"
#include "Log.hxx"
#include "LogInit.hxx"
...
...
src/ReplayGainConfig.hxx
View file @
77c1f548
...
...
@@ -21,14 +21,15 @@
#define MPD_REPLAY_GAIN_CONFIG_HXX
#include "check.h"
#include "ReplayGainMode.hxx"
extern
ReplayGainMode
replay_gain_mode
;
extern
float
replay_gain_preamp
;
extern
float
replay_gain_missing_preamp
;
extern
bool
replay_gain_limit
;
struct
ReplayGainConfig
{
static
constexpr
bool
DEFAULT_LIMIT
=
true
;
void
replay_gain_global_init
();
float
preamp
=
1.0
;
float
missing_preamp
=
1.0
;
bool
limit
=
DEFAULT_LIMIT
;
};
#endif
src/ReplayGain
Config
.cxx
→
src/ReplayGain
Global
.cxx
View file @
77c1f548
...
...
@@ -18,6 +18,7 @@
*/
#include "config.h"
#include "ReplayGainGlobal.hxx"
#include "ReplayGainConfig.hxx"
#include "config/Param.hxx"
#include "config/ConfigGlobal.hxx"
...
...
@@ -28,12 +29,7 @@
#include <math.h>
ReplayGainMode
replay_gain_mode
=
ReplayGainMode
::
OFF
;
static
constexpr
bool
DEFAULT_REPLAYGAIN_LIMIT
=
true
;
float
replay_gain_preamp
=
1.0
;
float
replay_gain_missing_preamp
=
1.0
;
bool
replay_gain_limit
=
DEFAULT_REPLAYGAIN_LIMIT
;
ReplayGainConfig
replay_gain_config
;
static
float
ParsePreamp
(
const
char
*
s
)
...
...
@@ -76,12 +72,12 @@ void replay_gain_global_init(void)
param
=
config_get_param
(
ConfigOption
::
REPLAYGAIN_PREAMP
);
if
(
param
)
replay_gain_preamp
=
ParsePreamp
(
*
param
);
replay_gain_
config
.
preamp
=
ParsePreamp
(
*
param
);
param
=
config_get_param
(
ConfigOption
::
REPLAYGAIN_MISSING_PREAMP
);
if
(
param
)
replay_gain_missing_preamp
=
ParsePreamp
(
*
param
);
replay_gain_
config
.
missing_preamp
=
ParsePreamp
(
*
param
);
replay_gain_limit
=
config_get_bool
(
ConfigOption
::
REPLAYGAIN_LIMIT
,
DEFAULT_REPLAYGAIN
_LIMIT
);
replay_gain_
config
.
limit
=
config_get_bool
(
ConfigOption
::
REPLAYGAIN_LIMIT
,
ReplayGainConfig
::
DEFAULT
_LIMIT
);
}
src/ReplayGainGlobal.hxx
0 → 100644
View file @
77c1f548
/*
* Copyright 2003-2016 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_REPLAY_GAIN_GLOBAL_HXX
#define MPD_REPLAY_GAIN_GLOBAL_HXX
#include "check.h"
#include "ReplayGainMode.hxx"
struct
ReplayGainConfig
;
extern
ReplayGainMode
replay_gain_mode
;
extern
ReplayGainConfig
replay_gain_config
;
void
replay_gain_global_init
();
#endif
src/ReplayGainInfo.cxx
View file @
77c1f548
...
...
@@ -19,25 +19,25 @@
#include "config.h"
#include "ReplayGainInfo.hxx"
#include "ReplayGainConfig.hxx"
#include <math.h>
float
ReplayGainTuple
::
CalculateScale
(
float
preamp
,
float
missing_preamp
,
bool
peak_limit
)
const
ReplayGainTuple
::
CalculateScale
(
const
ReplayGainConfig
&
config
)
const
{
float
scale
;
if
(
IsDefined
())
{
scale
=
pow
(
10.0
,
gain
/
20.0
);
scale
*=
preamp
;
scale
*=
config
.
preamp
;
if
(
scale
>
15.0
)
scale
=
15.0
;
if
(
peak_
limit
&&
scale
*
peak
>
1.0
)
if
(
config
.
limit
&&
scale
*
peak
>
1.0
)
scale
=
1.0
/
peak
;
}
else
scale
=
missing_preamp
;
scale
=
config
.
missing_preamp
;
return
scale
;
}
src/ReplayGainInfo.hxx
View file @
77c1f548
...
...
@@ -24,6 +24,8 @@
#include "Compiler.h"
#include "ReplayGainMode.hxx"
struct
ReplayGainConfig
;
struct
ReplayGainTuple
{
float
gain
;
float
peak
;
...
...
@@ -38,8 +40,7 @@ struct ReplayGainTuple {
}
gcc_pure
float
CalculateScale
(
float
preamp
,
float
missing_preamp
,
bool
peak_limit
)
const
;
float
CalculateScale
(
const
ReplayGainConfig
&
config
)
const
;
};
struct
ReplayGainInfo
{
...
...
src/command/PlayerCommands.cxx
View file @
77c1f548
...
...
@@ -30,7 +30,7 @@
#include "Instance.hxx"
#include "Idle.hxx"
#include "AudioFormat.hxx"
#include "ReplayGain
Config
.hxx"
#include "ReplayGain
Global
.hxx"
#include "util/ScopeExit.hxx"
#ifdef ENABLE_DATABASE
...
...
src/decoder/Bridge.cxx
View file @
77c1f548
...
...
@@ -30,7 +30,7 @@
#include "pcm/PcmConvert.hxx"
#include "tag/Tag.hxx"
#include "AudioConfig.hxx"
#include "ReplayGain
Config
.hxx"
#include "ReplayGain
Global
.hxx"
#include "Log.hxx"
#include "input/InputStream.hxx"
#include "util/ConstBuffer.hxx"
...
...
@@ -599,9 +599,7 @@ DecoderBridge::SubmitReplayGain(const ReplayGainInfo *new_replay_gain_info)
const
auto
&
tuple
=
new_replay_gain_info
->
Get
(
rgm
);
const
auto
scale
=
tuple
.
CalculateScale
(
replay_gain_preamp
,
replay_gain_missing_preamp
,
replay_gain_limit
);
tuple
.
CalculateScale
(
replay_gain_config
);
dc
.
replay_gain_db
=
20.0
*
log10f
(
scale
);
}
...
...
src/filter/plugins/ReplayGainFilterPlugin.cxx
View file @
77c1f548
...
...
@@ -24,7 +24,7 @@
#include "filter/FilterRegistry.hxx"
#include "AudioFormat.hxx"
#include "ReplayGainInfo.hxx"
#include "ReplayGain
Config
.hxx"
#include "ReplayGain
Global
.hxx"
#include "mixer/MixerControl.hxx"
#include "pcm/Volume.hxx"
#include "util/ConstBuffer.hxx"
...
...
@@ -140,9 +140,7 @@ ReplayGainFilter::Update()
unsigned
volume
=
PCM_VOLUME_1
;
if
(
mode
!=
ReplayGainMode
::
OFF
)
{
const
auto
&
tuple
=
info
.
Get
(
mode
);
float
scale
=
tuple
.
CalculateScale
(
replay_gain_preamp
,
replay_gain_missing_preamp
,
replay_gain_limit
);
float
scale
=
tuple
.
CalculateScale
(
replay_gain_config
);
FormatDebug
(
replay_gain_domain
,
"scale=%f
\n
"
,
(
double
)
scale
);
...
...
test/FakeReplayGain
Config
.cxx
→
test/FakeReplayGain
Global
.cxx
View file @
77c1f548
...
...
@@ -18,8 +18,7 @@
*/
#include "config.h"
#include "ReplayGainGlobal.hxx"
#include "ReplayGainConfig.hxx"
float
replay_gain_preamp
=
1.0
;
float
replay_gain_missing_preamp
=
1.0
;
bool
replay_gain_limit
=
true
;
ReplayGainConfig
replay_gain_config
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment