diff options
-rw-r--r-- | conf.c | 10 | ||||
-rw-r--r-- | conf.h | 1 | ||||
-rw-r--r-- | config-example | 18 | ||||
-rw-r--r-- | streamer.c | 34 |
4 files changed, 55 insertions, 8 deletions
@@ -27,6 +27,7 @@ char conf_hvsc_path[1024] = ""; int conf_hvsc_enable = 0; char conf_blacklist_plugins[1024]; // plugins listed in this option will not be loaded int conf_close_send_to_tray = 0; +int conf_replaygain_mode = 0; int conf_load (void) { @@ -93,6 +94,15 @@ conf_load (void) { else if (!strcasecmp (str, "close_send_to_tray")) { conf_close_send_to_tray = atoi (value); } + else if (!strcasecmp (str, "replaygain_mode")) { + int rg = atoi (value); + if (rg >= 0 && rg <= 2) { + conf_replaygain_mode = atoi (value); + } + else { + fprintf (stderr, "config warning: replaygain_mode must be one of 0, 1 or 2\n"); + } + } else { fprintf (stderr, "error in config file line %d\n", line); } @@ -25,6 +25,7 @@ extern char conf_hvsc_path[1024]; extern int conf_hvsc_enable; extern char conf_blacklist_plugins[1024]; extern int conf_close_send_to_tray; +extern int conf_replaygain_mode; int conf_load (void); diff --git a/config-example b/config-example index 7a5bf47e..104fe1f6 100644 --- a/config-example +++ b/config-example @@ -7,9 +7,12 @@ alsa_soundcard default # mixing frequency (samplerate) -# prefer native samplerate of your soundcard -# e.g. 48k for creative cards +# you should prefer native samplerate of your soundcard +# that's 48k for creative cards # consult your soundcard manual if you don't want to get crappy results +# this parameter heavily impacts quality and CPU use +# if you set this to wrong value - you will loose both +# default is 48000 samplerate 48000 # samplerate conversion quality @@ -26,7 +29,7 @@ samplerate 48000 src_quality 2 # default behaviour of close(X) button is to close player -# this option allows to minimize to tray instead +# set to 1 to minimize to tray instead #close_send_to_tray 1 # those next 2 are disabled by default, cause most people probably don't have HVSC @@ -36,4 +39,13 @@ src_quality 2 # plugin blacklisting # i use it for testing +# but it can also be used to save some memory by ignoring unused plugins #blacklist_plugins ape hotkeys + +# replay gain mode +# see http://wiki.hydrogenaudio.org/index.php?title=Replaygain for details +# 0 none (default) +# 1 track +# 2 album (audiophile) +# you must preprocess your collection with some external application to use that +replaygain_mode 0 @@ -372,15 +372,27 @@ streamer_reset (int full) { // must be called when current song changes by exter src_reset (src); } -int replaygain = 0; +int replaygain = 1; static void apply_replay_gain_int16 (playItem_t *it, char *bytes, int size) { - if (!replaygain) { + if (!replaygain || !conf_replaygain_mode) { return; } + int vol = 1000; + if (conf_replaygain_mode == 1) { + if (it->replaygain_track_gain == 0) { + return; + } + vol = db_to_amp (str_streaming_song.replaygain_track_gain) * 1000; + } + else if (conf_replaygain_mode == 2) { + if (it->replaygain_album_gain == 0) { + return; + } + vol = db_to_amp (str_streaming_song.replaygain_album_gain) * 1000; + } if (it->replaygain_track_gain != 0) { - int vol = db_to_amp (str_streaming_song.replaygain_track_gain) * 1000; int16_t *s = (int16_t*)bytes; for (int j = 0; j < size/2; j++) { int32_t sample = ((int32_t)*s) * vol / 1000; @@ -398,11 +410,23 @@ apply_replay_gain_int16 (playItem_t *it, char *bytes, int size) { static void apply_replay_gain_float32 (playItem_t *it, char *bytes, int size) { - if (!replaygain) { + if (!replaygain && !conf_replaygain_mode) { return; } + float vol = 1; + if (conf_replaygain_mode == 1) { + if (it->replaygain_track_gain == 0) { + return; + } + vol = db_to_amp (it->replaygain_track_gain); + } + else if (conf_replaygain_mode == 2) { + if (it->replaygain_album_gain == 0) { + return; + } + vol = db_to_amp (it->replaygain_album_gain); + } if (it->replaygain_track_gain != 0) { - float vol = db_to_amp (str_streaming_song.replaygain_track_gain); float *s = (float*)bytes; for (int j = 0; j < size/4; j++) { float sample = ((float)*s) * vol; |