mirror of
https://github.com/notwa/rc
synced 2024-11-05 04:29:03 -08:00
25 lines
861 B
Bash
Executable file
25 lines
861 B
Bash
Executable file
#!/usr/bin/zsh
|
|
# script to make sense of compand's parameters
|
|
# YES_ZSH
|
|
|
|
compandy() { ### @-
|
|
### generate compand arguments for ffmpeg audio filters.
|
|
### this is kinda pointless now that acompressor is wildly supported.
|
|
if [ $# -eq 0 ]; then
|
|
echo -E "usage: $0 {threshold} {ratio} [attack] [release] [knee] [gain] [delay]"
|
|
return 1
|
|
fi
|
|
local thresh="${1:-10}" ratio="${2:-2}"
|
|
local atk="${3:-1}" rel="${4:-100}"
|
|
local knee="${5:-1}" gain="${6:-0}" delay="${7:-0}"
|
|
let 'atk/=1000.'
|
|
let 'rel/=1000.'
|
|
let 'delay/=1000.'
|
|
local end= start=
|
|
let 'end=thresh - thresh/(ratio + 0.0)'
|
|
let 'start=thresh'
|
|
printf "compand=%.5f|%.5f:%.5f|%.5f:%.1f/%.1f|0/%.2f:%.2f:%.2f:%.1f:%.5f" \
|
|
$atk $atk $rel $rel $thresh $thresh $end $knee $gain $start $delay
|
|
}
|
|
|
|
[ "${SOURCING:-0}" -gt 0 ] || compandy "$@"
|