SoX FIR Single Line

I am trying to apply reverb by curling up with an impulse response in SoX. The following shell script does exactly what I want:

#!/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 $1`

# 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 $1 -r 44100 filter.dat

# extract the coeffients (second column, skipping the first 2 lines)
awk 'NR<3{next}{print $2}' filter.dat > filter.txt

# apply reverb using SoX fir effect (need front zero-padding to for
# the extra samples due to the convolution
sox "|sox $2 -p pad $IR_DUR 0" --norm $3 fir filter.txt

Question

How can I do this without temporary files (filter. *)? I know that the answer lies inside the pipes, but I cannot get it to work.

+4
source share
1 answer

After some trial and error, I found what I was looking for. In case anyone is interested in this, this is my solution:

sox --norm=-10 -c 1 $1 -r 44100 -t dat - | awk 'NR<3{next}{print $2;}' | sox "|sox $2 -p pad $d $d" --norm $3 fir -
+2
source

Source: https://habr.com/ru/post/1612069/


All Articles