Help
Difference between revisions of "SoX"
(→Fades) |
|||
Line 35: | Line 35: | ||
== Fades == | == Fades == | ||
− | To fade-in on 0.3s and out in 0.4s, you can use a simple bash script, as | + | To fade-in on 0.3s and out in 0.4s, you can use a simple ./fadeWav.sh bash script, such as: |
<pre>#! /bin/bash | <pre>#! /bin/bash | ||
Line 50: | Line 50: | ||
You can run this bash script as follows: | You can run this bash script as follows: | ||
− | <pre>./fadeWav test.wav faded.wav</pre> | + | <pre>./fadeWav.sh test.wav faded.wav</pre> |
=== Sources === | === Sources === | ||
* [https://stackoverflow.com/a/24307805?stw=2 Answer:SOX and fade in and fade out] | * [https://stackoverflow.com/a/24307805?stw=2 Answer:SOX and fade in and fade out] |
Revision as of 00:04, 27 December 2018
Dependencies
- SoX - Sound eXchange, the Swiss Army knife of audio manipulation
- FFmpeg - ffmpeg video converter
- -ss: the time offset from beginning. (
h:m:s.ms
). - -t duration: record or transcode duration seconds of audio/video.
- -ss: the time offset from beginning. (
Denoise
Extract noise file from silence + room’s noise
Given a file with silence in it’s first 0.3sec. :
# sox in.ext out.ext trim {start: s.ms} {duration: s.ms}
sox audio.wav noise-audio.wav trim 0 0.300
# or :
ffmpeg -i audio.wav -vn -ss 00:00:00 -t 00:00:00.300 noise-audio.wav
Generate a noise profile in sox:
sox noise-audio.wav -n noiseprof noise.prof
Clean the noise from the audio
Single file :
sox audio.wav audio-clean.wav noisered noise.prof 0.21
Batch of files:
mkdir -p ./clean; for file in ./*.wav;do key=$(basename "$file" .wav); sox "$file" ./clean/"$key".wav noisered ./noise.prof 0.21; done;
According to source :
Change 0.21 to adjust the level of sensitivity in the sampling rates (I found 0.2-0.3 often provides best result).
Sources
Fades
To fade-in on 0.3s and out in 0.4s, you can use a simple ./fadeWav.sh bash script, such as:
#! /bin/bash WAV_IN=$1 WAV_OUT=$2 FADE_IN_L="0:0.3" FADE_OUT_L="0:0.4" LENGTH=`soxi -d $WAV_IN` sox $WAV_IN $WAV_OUT fade $FADE_IN_L $LENGTH $FADE_OUT_L
soxi -d
returns the length of the wav file. See sox documentation for more on soxi.
You can run this bash script as follows:
./fadeWav.sh test.wav faded.wav