Skip to content

Instantly share code, notes, and snippets.

@gustavomdsantos
Last active May 25, 2025 14:05
Show Gist options
  • Save gustavomdsantos/13508509df4f2e3b965e3fd911fda460 to your computer and use it in GitHub Desktop.
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.
#!/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 %
"
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