Last active
May 25, 2025 14:05
-
-
Save gustavomdsantos/13508509df4f2e3b965e3fd911fda460 to your computer and use it in GitHub Desktop.
Volume Relative (VR) is an informal percentage unit of measurement based on Loudness Units Full Scale (LUFS). It is read similarly to Volume Unit (VU), with the target 100% = -6 LUFS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#=========================================== | |
# LUFS to Volume Relative (VR) Converter | |
# Simple implementation based on formula: | |
# VR = 9.09 * LUFS + 154.54 | |
#=========================================== | |
script_name="${SCRIPT_ALIAS:-$(basename "$0")}" | |
show_usage() { | |
local message=" | |
Usage: $script_name <LUFS_value> | |
Example: $script_name -14 | |
" | |
echo -e "$message" | |
} | |
if [ -z "${1:-}" ]; then | |
show_usage | |
exit 1 | |
fi | |
LUFS="$1" | |
# Validate if input is a number | |
if ! [[ "$LUFS" =~ ^-?[0-9]+([.][0-9]+)?$ ]]; then | |
echo -e " | |
Error: Invalid LUFS value. Must be a number. | |
" | |
exit 2 | |
fi | |
# Calculate VR | |
VR=$(awk "BEGIN { printf \"%.2f\", (9.09 * $LUFS) + 154.54 }") | |
# Output result | |
echo -e " | |
Input: $LUFS LUFS | |
Volume Relative (VR): $VR % | |
" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias vr='SCRIPT_ALIAS=vr /home/gusmd/.config/bash/lufs_to_vr.sh' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment