Recently, I was finding that the songs played by pianobar seemed very inconsistent in terms of volume levels. After digging into the issue a bit, it seems to be that the "fileGain" parameter sent along with every song is what was causing these variations. It seems that for most of the songs that my stations play, the gain reduction is too much. Thus, I added a config file setting to reduce the gain amount with a multiplier.
I personally have a Pandora One (Plus?) account, so I only use the high-quality streams. From a quick inspection of the audio files, it seems like the high-quality streams are 32-bit floatle AAC streams in an mp4 container. At least one of the songs I inspected had audio samples above 1.0, so it seems that the negative gain is necessary to prevent clipping (most of the songs I inspected called for negative gains in the range of -1 to -6 dB).
The example song I can point to is "Can't Kill Us" by "The Glitch Mob" on "Love Death Immortality". Here is the debug output for that track:
Note the requested gain amount of -5.82 dB. Upon inspecting the file in Audacity, the highest sample is at +3.81 dB (and that seems to be a stray transient). Realistically, this gain reduction makes the song play at half volume.
This patch may not be the best way of solving this problem, but I'm currently unable to come up with anything better. I'm definitely open to suggestions.
Recently, I was finding that the songs played by pianobar seemed very inconsistent in terms of volume levels. After digging into the issue a bit, it seems to be that the "fileGain" parameter sent along with every song is what was causing these variations. It seems that for most of the songs that my stations play, the gain reduction is too much. Thus, I added a config file setting to reduce the gain amount with a multiplier.
I personally have a Pandora One (Plus?) account, so I only use the high-quality streams. From a quick inspection of the audio files, it seems like the high-quality streams are 32-bit floatle AAC streams in an mp4 container. At least one of the songs I inspected had audio samples above 1.0, so it seems that the negative gain is necessary to prevent clipping (most of the songs I inspected called for negative gains in the range of -1 to -6 dB).
The example song I can point to is "Can't Kill Us" by "The Glitch Mob" on "Love Death Immortality". Here is the debug output for that track:
Note the requested gain amount of -5.82 dB. Upon inspecting the file in Audacity, the highest sample is at +3.81 dB (and that seems to be a stray transient). Realistically, this gain reduction makes the song play at half volume.
This patch may not be the best way of solving this problem, but I'm currently unable to come up with anything better. I'm definitely open to suggestions.