Skip to content

Commit

Permalink
Added gain_mul setting to soften effect of replaygain.
Browse files Browse the repository at this point in the history
  • Loading branch information
zootboy committed Mar 15, 2017
1 parent 9b26abb commit aaf5eae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions contrib/pianobar.1
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ Your pandora.com username.
.B volume = 0
Initial volume correction in dB. Usually between -30 and +5.

.TP
.B gain_mul = 1.0
Pandora sends a ReplayGain value with every song. This sets a multiplier so that the gain adjustment can be
reduced. 0.0 means no gain adjustment, 1.0 means full gain adjustment, values inbetween reduce the magnitude
of gain adjustment.

.SH REMOTE CONTROL
.B pianobar
can be controlled through a fifo. You have to create it yourself by executing
Expand Down
4 changes: 2 additions & 2 deletions src/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ void BarPlayerSetVolume (player_t * const player) {
* -> print to string and let them parse it again */
char strbuf[16];
snprintf (strbuf, sizeof (strbuf), "%fdB",
player->settings->volume + player->gain);
player->settings->volume + (player->gain * player->settings->gainMul));
assert (player->fgraph != NULL);
if ((ret = avfilter_graph_send_command (player->fgraph, "volume", "volume",
strbuf, NULL, 0, 0)) < 0) {
#else
/* convert from decibel */
const double volume = pow (10, (player->settings->volume + player->gain) / 20);
const double volume = pow (10, (player->settings->volume + (player->gain * player->settings->gainMul)) / 20);
/* libav does not provide other means to set this right now. it might not
* even work everywhere. */
assert (player->fvolume != NULL);
Expand Down
3 changes: 3 additions & 0 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ void BarSettingsRead (BarSettings_t *settings) {
settings->autoselect = true;
settings->history = 5;
settings->volume = 0;
settings->gainMul = 1.0;
settings->maxPlayerErrors = 5;
settings->sortOrder = BAR_SORT_NAME_AZ;
settings->loveIcon = strdup (" <3");
Expand Down Expand Up @@ -362,6 +363,8 @@ void BarSettingsRead (BarSettings_t *settings) {
settings->atIcon = strdup (val);
} else if (streq ("volume", key)) {
settings->volume = atoi (val);
} else if (streq ("gain_mul", key)) {
settings->gainMul = atof (val);
} else if (streq ("format_nowplaying_song", key)) {
free (settings->npSongFormat);
settings->npSongFormat = strdup (val);
Expand Down
1 change: 1 addition & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ typedef struct {
bool autoselect;
unsigned int history, maxPlayerErrors;
int volume;
float gainMul;
BarStationSorting_t sortOrder;
PianoAudioQuality_t audioQuality;
char *username;
Expand Down

0 comments on commit aaf5eae

Please sign in to comment.