Skip to content

Commit 1b90edd

Browse files
committed
* b -> t -> btop
* refinined some funcs' help messages * `f22448` (reads FLAC to 24bit/48kHz) - resamples Hi-Res audio to the mentioned format using high-quality soxr resampler
1 parent a621f6b commit 1b90edd

File tree

1 file changed

+42
-23
lines changed

1 file changed

+42
-23
lines changed

lib.sh

+42-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LIBSH_VERSION=20250302_eb4d524
1+
LIBSH_VERSION=20250308_a621f6b
22
export LIBSH_VERSION
33
cat <<EOF
44
lib.sh v$LIBSH_VERSION
@@ -291,6 +291,7 @@ alias kcont='k -SIGCONT'
291291
pk() { pg "$1" | x kill -9; }
292292

293293
alias t=btop
294+
alias b=btop
294295

295296
_salias bw bandwhich --show-dns
296297

@@ -1244,7 +1245,7 @@ alias nxhash='nx hash'
12441245
alias nxh='nxhash'
12451246

12461247
nxhrand() {
1247-
_require nix
1248+
_require nix || return 1
12481249
# branching to support Lix
12491250
if [[ "$(nix --version)" =~ Lix ]]; then
12501251
nxh to-sri --type sha256 $(rand 32) | tn
@@ -2191,7 +2192,6 @@ wttr() {
21912192
}
21922193

21932194
# FLAC to ALAC
2194-
#
21952195
function flac2alac() {
21962196
local _noart=0
21972197
case $1 in
@@ -2200,35 +2200,33 @@ function flac2alac() {
22002200
;;
22012201
-h | --help)
22022202
cat <<'EOF'
2203+
flac2alac [ <artwork file name>|--no-art|--no-cover ]
2204+
2205+
Recursively converts FLAC to ALAC, starting from the current directory.
22032206
2204-
flac2alac [ artwork ]
2205-
recursively converts FLAC to ALAC, starting from the current directory (.)
2207+
artwork file name: jpeg or png filename containing the artwork to be embedded in the
2208+
resulting m4a; searched in every subdir
22062209
2207-
artwork:
2208-
jpeg or png filename containing the artwork to be embedded in the
2209-
resulting m4a; searched in every subdir
2210+
default names being searched:
2211+
- cover.jpg
2212+
- cover.jpeg
2213+
- cover.png
22102214
2211-
default names being searched:
2212-
cover.jpg
2213-
cover.jpeg
2214-
cover.png
2215+
--no-art|--no-cover don't embed any art
22152216
22162217
EOF
2217-
return 1
22182218
;;
22192219
esac
2220+
22202221
_require ffmpeg || return 1
22212222

22222223
for f in ./**/*.flac; do
22232224
echo converting "$f" to "${f%.*}.m4a"...
22242225
ffmpeg -i "$f" -c:a alac -strict experimental -c:v copy "${f%.*}".m4a
22252226
done
22262227

2227-
_require atomicparsley && {
2228-
if [ $_noart = 1 ]; then
2229-
echo "not embedding artwork ($_noart)"
2230-
return
2231-
fi
2228+
if [ $_noart != 1 ]; then
2229+
_require atomicparsley || return 1
22322230

22332231
local _cnames=("$1" cover.jpg cover.jpeg cover.png)
22342232

@@ -2250,7 +2248,7 @@ EOF
22502248
echo not embedding artwork: "$_cover" does not exist
22512249
fi
22522250
done
2253-
}
2251+
fi
22542252
}
22552253

22562254
alias f2a=flac2alac
@@ -2320,11 +2318,11 @@ any2any <src files extensions> <dst codec> [ dst files extension ]
23202318
recursively converts source to destination.
23212319
if destination is not specified, flac is used.
23222320
2323-
e.g.:
2321+
Usage examples:
23242322
2325-
any2any ape alac m4a
2326-
any2any m4a flac
2327-
any2any flac alac m4a
2323+
any2any ape alac m4a
2324+
any2any m4a flac
2325+
any2any flac alac m4a
23282326
23292327
EOF
23302328
return 1
@@ -2353,6 +2351,27 @@ EOF
23532351

23542352
}
23552353

2354+
f22448() {
2355+
if [[ $1 =~ -h|--help ]]; then
2356+
cat <<'EOF'
2357+
Down-samples Hi-Res audio to 24bit / 48kHz.
2358+
Supplying audio with lower bit or sample rate is not supported.
2359+
2360+
Usage:
2361+
f22448
2362+
2363+
EOF
2364+
return 1
2365+
fi
2366+
2367+
_require ffmpeg || return 1
2368+
2369+
for f in ./**/*.flac; do
2370+
local dst="${f%.*}".24-48.flac
2371+
ffmpeg -i "$f" -c:a flac -sample_fmt s32 -ar 48000 -af "aresample=resampler=soxr" "$dst"
2372+
done
2373+
}
2374+
23562375
alias a2a=any2any
23572376

23582377
_wavpack() {

0 commit comments

Comments
 (0)