Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SoX FIR one-liner

Tags:

shell

audio

sox

I'm trying to apply reverb by convolving 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's 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

The Question

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

like image 346
jorgeh Avatar asked Sep 26 '22 11:09

jorgeh


People also ask

Are liner socks worth it?

Yes, sock liners do really work. Whether you choose to wear them alone or with a thicker pair of socks, sock liners are great for hiking in any weather. In hot weather, your feet sweat more. Wearing sock liners helps keep your feet dry and cool, even if it seems counter-intuitive.

What is the purpose of liner socks?

Sock liners are made of a thin polyester or lightweight wool material that help wick sweat away from your feet. You wear them under your thicker hiking sock and are mainly recommended as a preventive measure to getting blisters.

Can you wear sock liners as socks?

Liners as Standalone SocksYou can wear the liner sock on its own on extra-hot days or for your tighter fitting shoes. The moisture-wicking qualities will still keep your feet cool and dry, and you'll have even less bulk than with a two-sock system.


1 Answers

After some trial and error, I found what I was looking for. In case anyone out there is interested, 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 -
like image 72
jorgeh Avatar answered Sep 29 '22 01:09

jorgeh