Repository: beetbox/beets

Issue:
R128_*_GAIN tags are rounded or truncated
<!--
Describe your problem, feature request, or discussion topic here.

Please fill out this and the "Setup" section below and remember to include
enough detail so that other people can reproduce the problem.
-->

### Problem

Running this command in verbose (`-vv`) mode:

```sh
$ beet -vv replaygain -a "a matter of life and death"
```

Led to this problem:

```
user configuration: /home/streetwalrus/.config/beets/config.yaml
data directory: /home/streetwalrus/.config/beets
plugin paths: 
Sending event: pluginload
library database: /home/streetwalrus/music/beets.blb
library directory: /home/streetwalrus/music
Sending event: library_opened
replaygain: Analyzing 1 albums ~ ffmpeg backend...
replaygain: analyzing Iron Maiden - A Matter of Life and Death
replaygain: analyzing Iron Maiden - A Matter of Life and Death - Different World
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/01 Different World.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - Different World: 2517 blocks over -18.7 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - Different World: gain -5.4 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - These Colours Don't Run
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/02 These Colours Don't Run.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - These Colours Don't Run: 3872 blocks over -20.0 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - These Colours Don't Run: gain -4.199999999999999 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - Brighter Than a Thousand Suns
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/03 Brighter Than a Thousand Suns.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - Brighter Than a Thousand Suns: 5082 blocks over -20.0 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - Brighter Than a Thousand Suns: gain -4.1 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - The Pilgrim
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/04 The Pilgrim.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - The Pilgrim: 3022 blocks over -18.6 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - The Pilgrim: gain -5.4 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - The Longest Day
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/05 The Longest Day.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - The Longest Day: 4579 blocks over -19.5 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - The Longest Day: gain -4.6 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - Out of the Shadows
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/06 Out of the Shadows.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - Out of the Shadows: 3316 blocks over -19.6 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - Out of the Shadows: gain -4.5 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - The Reincarnation of Benjamin Breeg
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/07 The Reincarnation of Benjamin Breeg.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - The Reincarnation of Benjamin Breeg: 3931 blocks over -20.2 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - The Reincarnation of Benjamin Breeg: gain -4.199999999999999 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - For the Greater Good of God
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/08 For the Greater Good of God.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - For the Greater Good of God: 5575 blocks over -19.3 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - For the Greater Good of God: gain -4.699999999999999 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - Lord of Light
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/09 Lord of Light.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - Lord of Light: 4384 blocks over -20.4 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - Lord of Light: gain -3.6999999999999993 LU, peak 0
replaygain: analyzing Iron Maiden - A Matter of Life and Death - The Legacy
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/10 The Legacy.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - The Legacy: 4785 blocks over -20.6 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - The Legacy: gain -4.1 LU, peak 0
replaygain: [Item(id=3406, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/01 Different World.flac', album_id=265, title='Different World', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=1, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='4ff68a16-0999-4702-964f-6c9dc82235df', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-5.4, rg_track_peak=0.9225714271547631, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-5, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=258.1769479166667, bitrate=3051907, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3401, path=b"/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/02 These Colours Don't Run.flac", album_id=265, title="These Colours Don't Run", artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=2, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='23bb40a3-109c-4296-a238-42133096be9e', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-4.199999999999999, rg_track_peak=0.954992586021436, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-4, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=412.21316666666667, bitrate=3040916, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3405, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/03 Brighter Than a Thousand Suns.flac', album_id=265, title='Brighter Than a Thousand Suns', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=3, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='9f253d2d-2147-4790-991e-cd2dfe5547fb', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-4.1, rg_track_peak=0.9120108393559098, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-4, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=526.1221666666667, bitrate=3008059, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3402, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/04 The Pilgrim.flac', album_id=265, title='The Pilgrim', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=4, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='72dbf4aa-3776-4c1d-ad4e-fd183fa8b4d7', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-5.4, rg_track_peak=0.954992586021436, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-5, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=307.8536041666667, bitrate=3123613, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3399, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/05 The Longest Day.flac', album_id=265, title='The Longest Day', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=5, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='eedabc25-0497-420d-a3c1-92295205955f', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-4.6, rg_track_peak=0.9885530946569389, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-5, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=468.0979375, bitrate=2999957, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3404, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/06 Out of the Shadows.flac', album_id=265, title='Out of the Shadows', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=6, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='dba49ffd-4eeb-4fef-bdca-e6176a263668', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-4.5, rg_track_peak=1.0471285480508996, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-4, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=336.63379166666664, bitrate=3029328, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3397, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/07 The Reincarnation of Benjamin Breeg.flac', album_id=265, title='The Reincarnation of Benjamin Breeg', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=7, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='076ccee2-d83a-4a49-8338-9698b68c344d', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-4.199999999999999, rg_track_peak=0.9440608762859234, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-4, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=442.06395833333335, bitrate=2975691, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3400, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/08 For the Greater Good of God.flac', album_id=265, title='For the Greater Good of God', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=8, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='f4fb05ae-f16d-4266-bc80-6ed3cea38429', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-4.699999999999999, rg_track_peak=0.9440608762859234, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-5, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=565.02503125, bitrate=3115563, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3398, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/09 Lord of Light.flac', album_id=265, title='Lord of Light', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=9, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='85915896-1f02-4835-aebb-f0bd3464fd4f', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-3.6999999999999993, rg_track_peak=0.933254300796991, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-4, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=444.65034375, bitrate=2936702, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz'), Item(id=3403, path=b'/home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/10 The Legacy.flac', album_id=265, title='The Legacy', artist='Iron Maiden', artist_sort='Iron Maiden', artist_credit='Iron Maiden', album='A Matter of Life and Death', albumartist='Iron Maiden', albumartist_sort='Iron Maiden', albumartist_credit='Iron Maiden', genre='Heavy Metal', style='', discogs_albumid=0, discogs_artistid=0, discogs_labelid=0, lyricist='', composer='', composer_sort='', work='', mb_workid='', work_disambig='', arranger='', grouping='', year=2006, month=0, day=0, track=10, tracktotal=10, disc=1, disctotal=1, lyrics='', comments='', bpm=0, comp=0, mb_trackid='5ca687ac-c1ce-42a2-b0e3-9879396b9192', mb_albumid='46e0f7f4-f702-38c0-a6f7-c9569e61b3d8', mb_artistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_albumartistid='ca891d65-d9b0-4258-89f7-e6ba29d83767', mb_releasetrackid='', trackdisambig='', albumtype='album', label='EMI', acoustid_fingerprint='', acoustid_id='', mb_releasegroupid='f27a9426-7f13-3c21-8861-204e42a82bd8', asin='B000GRU6XI', isrc='', catalognum='0946 372321 2 5', script='Latn', language='eng', country='XE', albumstatus='Official', media='CD', albumdisambig='', releasegroupdisambig='', disctitle='', encoder='', rg_track_gain=-4.1, rg_track_peak=0.933254300796991, rg_album_gain=-4.448753403915745, rg_album_peak=1.0471285480508996, r128_track_gain=-4, r128_album_gain=-4, original_year=2006, original_month=8, original_day=28, initial_key=None, length=562.9385208333333, bitrate=3013178, format='FLAC', samplerate=96000, bitdepth=24, channels=2, mtime=0.0, added=1439311230.369512, data_source='MusicBrainz')]: gain -4.448753403915745 LU, peak 0
Sending event: database_change
replaygain: applied r128 track gain -5 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - Different World
Sending event: database_change
replaygain: applied r128 track gain -4 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - These Colours Don't Run
Sending event: database_change
replaygain: applied r128 track gain -4 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - Brighter Than a Thousand Suns
Sending event: database_change
replaygain: applied r128 track gain -5 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - The Pilgrim
Sending event: database_change
replaygain: applied r128 track gain -5 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - The Longest Day
Sending event: database_change
replaygain: applied r128 track gain -4 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - Out of the Shadows
Sending event: database_change
replaygain: applied r128 track gain -4 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - The Reincarnation of Benjamin Breeg
Sending event: database_change
replaygain: applied r128 track gain -5 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - For the Greater Good of God
Sending event: database_change
replaygain: applied r128 track gain -4 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - Lord of Light
Sending event: database_change
replaygain: applied r128 track gain -4 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - The Legacy
Sending event: cli_exit
```

The calculated gain for all of these tracks gets rounded to an integer value when stored as R128. ReplayGain tags are fine (confirmed by looking at the tags with ffprobe, where RG stores -4.45, R128 is -1024, or -4 * 256). Querying those tags with `beet ls "a matter of life and death" -f '$r128_album_gain $r128_track_gain'` also gives an integer value. I believe this is due to the fact that those tags are NullPaddedInt in the database:
https://github.com/beetbox/beets/blob/3c7853712f83aafb3a9aa7b1c2943b45858e660f/beets/library.py#L518-L519


### Setup

* OS: Arch Linux
* Python version: 3.9.7
* beets version: 1.5.0
* Turning off plugins made problem go away (yes/no): this is a problem with the replaygain plugin

<!--
You can turn off plugins temporarily by passing --plugins= on the command line:

$ beet --plugins= version
-->

My configuration (output of `beet config`) is:

```yaml
library: ~/music/beets.blb
directory: ~/music

plugins: fetchart embedart replaygain

import:
    copy: yes
    group_albums: yes
embedart:
    auto: no
    maxwidth: 0
    compare_threshold: 0
    ifempty: no
    remove_art_file: no
    quality: 0
replaygain:
    backend: ffmpeg
    overwrite: yes
    targetlevel: 93
    r128_targetlevel: 93
    r128: FLAC
    auto: yes
    threads: 12
    parallel_on_import: no
    per_disc: no
    peak: 'true'
fetchart:
    auto: yes
    minwidth: 0
    maxwidth: 0
    quality: 0
    max_filesize: 0
    enforce_ratio: no
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    lastfm_key: REDACTED
    store_source: no
    high_resolution: no
```



Discussion:
Do you think you could provide a little more context about what you're looking at here? It's hard to see exactly what output is the relevant stuff. This might be a good place for answering a "what did you expect to see, and what was the actual behavior?" type of question.
Sorry, I was so caught up in testing I didn't think to highlight relevant parts of the log. See for example these bits for the first track of the album:

```
replaygain: analyzing Iron Maiden - A Matter of Life and Death - Different World
replaygain: executing ffmpeg -nostats -hide_banner -i /home/streetwalrus/music/Iron Maiden/A Matter of Life and Death/01 Different World.flac -map a:0 -filter ebur128=peak=none -f null -
replaygain: Iron Maiden - A Matter of Life and Death - Different World: 2517 blocks over -18.7 LUFS
replaygain: Iron Maiden - A Matter of Life and Death - Different World: gain -5.4 LU, peak 0
```

```
Sending event: database_change
replaygain: applied r128 track gain -5 LU
Sending event: database_change
replaygain: applied r128 album gain -4 LU
Sending event: write
Sending event: after_write
replaygain: done analyzing Iron Maiden - A Matter of Life and Death - Different World
```

As you can see here, the computed gain for this track is -5.4 LU, but it stores -5 LU into the database. Inspecting the tags with ffprobe, R128_TRACK_GAIN is set to -1280 which is -5 in Q7.8 representation (-5 * 256). The expected value of the tag is -1382 (-5.4 * 256), and the database should either store a float or the actual value of the tag.
Got it; thank you!! This definitely looks like a problem. It seems like the solution might be to use `NullFloat` here instead of `NullPaddedInt`… but it would require some careful thought to make sure we're not disrupting anything with the change.

For anyone interested in tackling this, it would be useful to do some `git blame` digging to see where this type came from and check whether there's any useful info in the associated discussion threads.
As far as I understand from digging around, it seems beets originally stored the raw Q7.8 value as an integer in the database, but it was later changed to store a value similar to replaygain, and conversion was moved to mediafile.
Looks like it was changed to `NullPaddedInt` to make it nullable in #2757, and it [started out as regular integers](https://github.com/autrimpo/beets/commit/2685f133152c6b059ab116560c5ee357c6550404#diff-d6c57a8deb6bf406de08bd231833fafb4515c984bf0d854a50a0e6cb3dcd3d1fR457).
Maybe it was originally intended to be Q7.8 in `beets` but never got implemented? 
If we keep using LU internally (I guess that was the conclusion ~ #3311) making these fields floats makes more sense.

I've checked whether we can just change it to `NullFloat`, seems like we can:
```
Sending event: database_change
replaygain: applied r128 track gain -13.3 LU
Sending event: database_change
replaygain: applied r128 album gain -14.487821730577789 LU
Sending event: write
Sending event: after_write
```
I've also confirmed that `mediafile` handles the floats just as well; as @9ary described above: e.g. -13.3 * 256 -> -3405 in my case

As far as I can tell `beets` only ever uses those fields in the RG plugin, I don't think there would be any issues with changing it.







Resolving patch:
diff --git a/beets/library.py b/beets/library.py
--- a/beets/library.py
+++ b/beets/library.py
@@ -515,8 +515,8 @@ class Item(LibModel):
         'rg_track_peak': types.NULL_FLOAT,
         'rg_album_gain': types.NULL_FLOAT,
         'rg_album_peak': types.NULL_FLOAT,
-        'r128_track_gain': types.NullPaddedInt(6),
-        'r128_album_gain': types.NullPaddedInt(6),
+        'r128_track_gain': types.NULL_FLOAT,
+        'r128_album_gain': types.NULL_FLOAT,
         'original_year': types.PaddedInt(4),
         'original_month': types.PaddedInt(2),
         'original_day': types.PaddedInt(2),
@@ -1058,7 +1058,7 @@ class Album(LibModel):
         'releasegroupdisambig': types.STRING,
         'rg_album_gain': types.NULL_FLOAT,
         'rg_album_peak': types.NULL_FLOAT,
-        'r128_album_gain': types.NullPaddedInt(6),
+        'r128_album_gain': types.NULL_FLOAT,
         'original_year': types.PaddedInt(4),
         'original_month': types.PaddedInt(2),
         'original_day': types.PaddedInt(2),


Test patch: