Add option to use album gain instead of track gain

This commit is contained in:
2022-04-20 00:21:32 -04:00
parent c9a31dcbce
commit f79d6ce025
+16
View File
@@ -61,6 +61,20 @@ def scan_destination_convert():
print(f"\n{_progress}% | \u001b[38;5;0;48;5;15mConverting {_file_s} to {_file_d}...\u001b[0m\n") print(f"\n{_progress}% | \u001b[38;5;0;48;5;15mConverting {_file_s} to {_file_d}...\u001b[0m\n")
# get relevant ReplayGain info # get relevant ReplayGain info
_audio = FLAC(f"{_file}.flac") _audio = FLAC(f"{_file}.flac")
if args.albumgain:
if _audio.get('replaygain_album_gain'):
_rggain = float(_audio.get('replaygain_album_gain')[0][:-3])
elif _audio.get('REPLAYGAIN_ALBUM_GAIN'):
_rggain = float(_audio.get('REPLAYGAIN_ALBUM_GAIN')[0][:-3])
else:
_rggain = None
if _audio.get('replaygain_album_peak'):
_rgpeak = float(_audio.get('replaygain_album_peak')[0])
elif _audio.get('REPLAYGAIN_ALBUM_PEAK'):
_rgpeak = float(_audio.get('REPLAYGAIN_ALBUM_PEAK')[0])
else:
_rgpeak = None
else:
if _audio.get('replaygain_track_gain'): if _audio.get('replaygain_track_gain'):
_rggain = float(_audio.get('replaygain_track_gain')[0][:-3]) _rggain = float(_audio.get('replaygain_track_gain')[0][:-3])
elif _audio.get('REPLAYGAIN_TRACK_GAIN'): elif _audio.get('REPLAYGAIN_TRACK_GAIN'):
@@ -108,6 +122,8 @@ if __name__ == "__main__":
help='strip all TXXX, APIC, and covr tags from the output files') help='strip all TXXX, APIC, and covr tags from the output files')
parser.add_argument('-b', '--bake', action='store_true', parser.add_argument('-b', '--bake', action='store_true',
help='bake (encode) ReplayGain values into the file instead of using SoundCheck tags') help='bake (encode) ReplayGain values into the file instead of using SoundCheck tags')
parser.add_argument('--albumgain', action='store_true',
help='read ReplayGain album gain instead of ReplayGain track gain')
args = parser.parse_args() args = parser.parse_args()
if args.source_dir[0].endswith('/'): if args.source_dir[0].endswith('/'):