单衬袜
SoX FIR one-liner
我正在尝试通过与 SoX 中的脉冲响应进行卷积来应用混响。以下 shell 脚本完全符合我的要求:
#!/usr/bin/env bash
#
# Convolve audio file with and impulse response (IR)
#
# Usage:
#
# applyReverb.sh <ir.wav> <audio.wav> <output.wav>
# IR duration (needed for zero-padding to prevent SoX from cutting
# the resulting audio after applying the FIR filter
IR_DUR=`soxi -D `
# read IR from wav, resample it if necessary, make sure is mono
# and save it as plain text (.dat format in SoX). Also reduces gain
# to prevent clipping later
sox --norm=-10 -c 1 -r 44100 filter.dat
# extract the coeffients (second column, skipping the first 2 lines)
awk 'NR<3{next}{print }' filter.dat > filter.txt
# apply reverb using SoX's fir effect (need front zero-padding to for
# the extra samples due to the convolution
sox "|sox -p pad $IR_DUR 0" --norm fir filter.txt
问题
如果没有临时文件 (filter.*),我该怎么做?我知道答案就在管道中,但我无法让它发挥作用。
经过反复试验,我找到了我要找的东西。如果有人感兴趣,这是我的解决方案:
sox --norm=-10 -c 1 -r 44100 -t dat - | awk 'NR<3{next}{print ;}' | sox "|sox -p pad $d $d" --norm fir -
我正在尝试通过与 SoX 中的脉冲响应进行卷积来应用混响。以下 shell 脚本完全符合我的要求:
#!/usr/bin/env bash
#
# Convolve audio file with and impulse response (IR)
#
# Usage:
#
# applyReverb.sh <ir.wav> <audio.wav> <output.wav>
# IR duration (needed for zero-padding to prevent SoX from cutting
# the resulting audio after applying the FIR filter
IR_DUR=`soxi -D `
# read IR from wav, resample it if necessary, make sure is mono
# and save it as plain text (.dat format in SoX). Also reduces gain
# to prevent clipping later
sox --norm=-10 -c 1 -r 44100 filter.dat
# extract the coeffients (second column, skipping the first 2 lines)
awk 'NR<3{next}{print }' filter.dat > filter.txt
# apply reverb using SoX's fir effect (need front zero-padding to for
# the extra samples due to the convolution
sox "|sox -p pad $IR_DUR 0" --norm fir filter.txt
问题
如果没有临时文件 (filter.*),我该怎么做?我知道答案就在管道中,但我无法让它发挥作用。
经过反复试验,我找到了我要找的东西。如果有人感兴趣,这是我的解决方案:
sox --norm=-10 -c 1 -r 44100 -t dat - | awk 'NR<3{next}{print ;}' | sox "|sox -p pad $d $d" --norm fir -