diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-07-17 14:54:22 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-07-17 14:54:22 +0000 |
commit | efda73c74dd379b30bf56fcff89eee9338acc02f (patch) | |
tree | ab99529448243510a8b18013f715ba8e382d72e1 /src | |
parent | 3edf33154308eafe212a0d536612b030e95ffc70 (diff) | |
download | mpd-efda73c74dd379b30bf56fcff89eee9338acc02f.tar.gz mpd-efda73c74dd379b30bf56fcff89eee9338acc02f.tar.xz mpd-efda73c74dd379b30bf56fcff89eee9338acc02f.zip |
add replaygain preamp
git-svn-id: https://svn.musicpd.org/mpd/trunk@1873 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/conf.c | 5 | ||||
-rw-r--r-- | src/conf.h | 1 | ||||
-rw-r--r-- | src/replayGain.c | 25 |
3 files changed, 28 insertions, 3 deletions
diff --git a/src/conf.c b/src/conf.c index c92546023..1eadc36fe 100644 --- a/src/conf.c +++ b/src/conf.c @@ -37,7 +37,7 @@ #define CONF_COMMENT '#' -#define CONF_NUMBER_OF_PARAMS 33 +#define CONF_NUMBER_OF_PARAMS 34 #define CONF_NUMBER_OF_PATHS 6 #define CONF_NUMBER_OF_REQUIRED 5 #define CONF_NUMBER_OF_ALLOW_CATS 1 @@ -129,7 +129,8 @@ char ** readConf(char * file) { "http_proxy_host", "http_proxy_port", "http_proxy_user", - "http_proxy_password" + "http_proxy_password", + "replaygain_preamp" }; int conf_absolutePaths[CONF_NUMBER_OF_PATHS] = { diff --git a/src/conf.h b/src/conf.h index 1a7c7fef0..6a06b0f0b 100644 --- a/src/conf.h +++ b/src/conf.h @@ -54,6 +54,7 @@ #define CONF_HTTP_PROXY_PORT 30 #define CONF_HTTP_PROXY_USER 31 #define CONF_HTTP_PROXY_PASSWORD 32 +#define CONF_REPLAYGAIN_PREAMP 33 #define CONF_CAT_CHAR "\n" diff --git a/src/replayGain.c b/src/replayGain.c index db401b4d1..dbd09aa36 100644 --- a/src/replayGain.c +++ b/src/replayGain.c @@ -29,6 +29,8 @@ /* Added 4/14/2004 by AliasMrJones */ static int replayGainState = REPLAYGAIN_OFF; +static float replayGainPreamp = 1.0; + void initReplayGainState() { if(!getConf()[CONF_REPLAYGAIN]) return; @@ -43,17 +45,38 @@ void initReplayGainState() { getConf()[CONF_REPLAYGAIN]); exit(EXIT_FAILURE); } + + if(getConf()[CONF_REPLAYGAIN_PREAMP]) { + char * test; + float f = strtod(getConf()[CONF_REPLAYGAIN_PREAMP], &test); + + if(*test != '\0') { + ERROR("Replaygain preamp \"%s\" is not a number\n", + getConf()[CONF_REPLAYGAIN_PREAMP]); + exit(EXIT_FAILURE); + } + + if(f < -15 || f > 15) { + ERROR("Replaygain preamp \"%s\" is not between -15 and" + "15\n", + getConf()[CONF_REPLAYGAIN_PREAMP]); + exit(EXIT_FAILURE); + } + + replayGainPreamp = pow(10, f/20.0); + } } int getReplayGainState() { return replayGainState; } -float computeReplayGainScale(float gain, float peak){ +float computeReplayGainScale(float gain, float peak) { float scale; if(gain == 0.0) return(1); scale = pow(10.0, gain/20.0); + scale*= replayGainPreamp; if(scale > 15.0) scale = 15.0; if (scale * peak > 1.0) { |