rsgain

repository·master·Indexed 20 days ago

https://github.com/complexlogic/rsgain

A ReplayGain 2.0 command line utility used to apply loudness metadata tags to audio files without altering the audio stream. It features a 'batteries included' approach for scanning music libraries across Windows, macOS, Linux, FreeBSD, Android, and Docker. It supports a wide range of formats including FLAC, MP3, Opus, and WAV, and can be used as a backend for the MusicBrainz Picard ReplayGain 2.0 plugin.

Tokens
6.4K
Snippets
23
Records
33
Agent score
71%

What's inside rsgain

  1. What is rsgain?

    master

    rsgain (really simple gain) is a ReplayGain 2.0 command line utility. It applies loudness metadata tags to audio files without altering the audio stream itself. When used with a ReplayGain-compatible player, the player will dynamically adjust the volume based on these tags.

    Key characteristics:

    • Batteries included: Designed to scan entire music libraries without external scripts.
    • Multiple interfaces: Available as a CLI or as a backend for the MusicBrainz Picard ReplayGain 2.0 plugin (which provides a GUI).
  2. Choose between Sample Peak and True Peak measurement

    master

    When scanning, you can choose how the peak value (used to predict clipping) is calculated.

    • Sample Peak (Default): The highest value sample in the signal. It is faster to calculate.
    • True Peak: Uses interpolation to approximate the original analog signal, accounting for intersample peaks. This is more accurate but significantly slower (typically 2-4x longer scans) due to the computational intensity of the oversampling process.
  3. Configure scanning with Scan Presets

    master

    Presets allow you to override default Easy Mode settings using an INI-formatted file. You can specify a preset via the -p option followed by the preset name or file path.

    Preset Locations:

    • Windows: %USERPROFILE%\.rsgain\presets or the presets folder containing rsgain.exe.
    • macOS: ~/Library/rsgain/presets or <install prefix>/share/rsgain/presets.
    • Linux: ~/.config/rsgain/presets or <install prefix>/share/rsgain/presets.

    Preset Logic:

    • The [Global] section applies to all formats.
    • Format-specific sections (e.g., [Opus]) apply only if all files in a directory are of that type.
    • Format-specific settings override [Global] settings.
    • Settings are applied in an "overrides" fashion; any key omitted will use the default value.

    Example: Using a built-in preset:

    # Use the EBU R 128 recommendation preset
    rsgain easy -p ebur128 /path/to/music/library
    rsgain easy -p ebur128 /path/to/music/library
  4. Skip existing ReplayGain tags in Easy Mode

    master

    To avoid re-scanning files that already contain ReplayGain information, use the -S or --skip-existing flag.

    Behavioral details:

    • It checks for the existence of the REPLAYGAIN_TRACK_GAIN tag.
    • If album tags are enabled, the check is collective: if even one file in an album is missing the tags, the entire album is scanned.
    • It does not verify if existing tags are complete or compatible with your current target loudness settings.
    rsgain easy -S /path/to/music/library
  5. Install rsgain on Linux

    master

    rsgain is available across various Linux distributions:

    Debian/Ubuntu

    • Debian 13 (Trixie) / Ubuntu 24.04 (noble): sudo apt install rsgain
    • Debian Bookworm: Download the .deb from the release page and install via:
      wget https://github.com/complexlogic/rsgain/releases/download/v3.7/rsgain_3.7-1_amd64.deb
      sudo apt install ./rsgain_3.7-1_amd64.deb
      Note: The .deb package for Bookworm may not work on newer Ubuntu releases due to FFmpeg ABI breaks.

    Arch/Manjaro

    Install via an AUR helper like yay:

    yay -S rsgain

    Fedora

    sudo dnf install rsgain

    Nix/NixOS

    • Run without installing: nix run nixpkgs#rsgain
    • Install in Nix environment: nix-env -f '<nixpkgs>' -iA rsgain
    • Add to NixOS configuration: Add rsgain to environment.systemPackages in your configuration.

    Static Build

    For most GNU-based distros (GCC 10+), you can use the x86_64 static TAR archive from the release page.

    # Debian/Ubuntu (Debian 13+ or Ubuntu 24.04+)
    sudo apt install rsgain
    
    # Arch/Manjaro
    yay -S rsgain
    
    # Fedora
    sudo dnf install rsgain
    
    # Nix (Run)
    nix run nixpkgs#rsgain
  6. Windows compatibility and Unicode support

    master

    rsgain uses UTF-8 for Unicode. To ensure full compatibility with all filenames (including those with non-ANSI characters), it is strongly recommended to run rsgain on Windows 10 version 1903 or later, which provides full UTF-8 support.

    If you are using Windows Vista through 8.1, rsgain will still function, but it will only work correctly if your filenames do not contain Unicode/non-ANSI characters.

  7. Build rsgain on Windows

    master

    Building on Windows requires Visual Studio (with C++ core desktop features and C++ CMake tools), Git, and CMake. It uses vcpkg to manage dependencies.

    1. Clone and Prepare: Clone the repository and create a build directory.
    2. Configure: Run cmake with the -DVCPKG=ON flag to build dependencies via vcpkg and generate Visual Studio project files.
    3. Build: Use cmake --build to compile the project.
    4. Run: Execute the resulting .exe from the Release folder.

    Optional: To generate a zipped install package, use the --target package flag during the build step.

    git clone https://github.com/complexlogic/rsgain.git
    cd rsgain
    mkdir build
    cd build
    cmake .. -DVCPKG=ON
    cmake --build . --config Release
    .\Release\rsgain.exe
  8. Generate .deb packages for rsgain

    master

    The build system supports creating Debian packages using CPack.

    1. Configure CMake with -DPACKAGE=DEB and set the install prefix (e.g., -DCMAKE_INSTALL_PREFIX=/usr).
    2. To target a specific architecture, use -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=architecture.
    3. Run make package to build the package.

    Example for amd64:

    cmake .. -DPACKAGE=DEB -DCMAKE_INSTALL_PREFIX=/usr
    make package
  9. Install rsgain on macOS

    master

    Portable Binaries

    Download the correct ZIP for your hardware from the Release Page:

    • Apple Silicon: rsgain-3.7-macOS-arm64.zip
    • Intel: rsgain-3.7-macOS-x86_64.zip

    Note on Gatekeeper: Since these builds are not codesigned, macOS may block execution. To allow it, remove the quarantine bit using xattr:

    xattr -d com.apple.quarantine /path/to/rsgain

    Package Managers

    Install via Homebrew or MacPorts:

    • Homebrew: brew install rsgain
    • MacPorts: port install rsgain
  10. Integrate rsgain with MusicBrainz Picard

    master

    You can use rsgain as a backend for the ReplayGain 2.0 plugin in MusicBrainz Picard to provide a GUI for ReplayGain calculations.

    Setup Steps:

    1. Install Plugin: In Picard, go to Options -> Plugins, find ReplayGain 2.0, and click download.
    2. Install rsgain: Ensure rsgain is installed on your system separately.
    3. Configure Path: In the plugin settings, set the path to the rsgain executable.
      • On Unix, rsgain is usually in your PATH.
      • On Windows, provide the full path to rsgain.exe or add its folder to your system Path.
    4. Calculate Gain:
      • Add files to Picard and associate them with a release.
      • Right-click an album or track and select Plugins -> Calculate ReplayGain.
      • Important: This calculates the values but does not tag them. You must click the Save button in Picard to write the tags to the files.
  11. Install dependencies for rsgain by package manager

    master

    Install the required development libraries based on your Linux distribution or OS:

    APT (Debian, Ubuntu, Mint)

    sudo apt install libebur128-dev libtag1-dev libavformat-dev libavcodec-dev libswresample-dev libavutil-dev libfmt-dev libinih-dev

    Pacman (Arch, Manjaro)

    sudo pacman -S libebur128 taglib ffmpeg fmt libinih

    DNF (Fedora)

    Note: FFmpeg is only in official repos for Fedora 36 and later.

    sudo dnf install libebur128-devel taglib-devel libavformat-free-devel libavcodec-free-devel libswresample-free-devel libavutil-free-devel fmt-devel inih-devel

    Portage (Gentoo, LiGurOS, Xenia)

    sudo emerge --ask --noreplace --tree media-libs/libebur128 media-libs/taglib media-video/ffmpeg dev-libs/inih dev-libs/libfmt

    Homebrew (macOS)

    brew install libebur128 taglib ffmpeg fmt inih

    Packages (FreeBSD)

    pkg install ebur128 taglib libfmt inih ffmpeg
  12. Use Custom Mode for scripting and specific files

    master

    Custom Mode is a legacy-style interface similar to mp3gain. Unlike Easy Mode, it operates on specific files rather than directories and is intended for users requiring high control or for use in scripts.

    Usage: Invoke with rsgain custom followed by options and a list of files.

    Example: Scan and tag specific MP3 files with album tags enabled (-a) and specific tag mode (-s i):

    rsgain custom -a -s i file1.mp3 file2.mp3 file3.mp3

    Run rsgain custom -h for the full list of available options.