[LAD] Normalize and Cut Wav
lsutton at libero.it
Wed Mar 9 08:55:32 UTC 2011
Alfs Kurmis wrote:
> Hi experts.
> I have started my small project - mp3 database for radio.
> How do i normalize by peak [not RMS] and trim silences in begin and
> end of WAV files ?
> Silences somewhere in middle of file i wanna leave untouched.
For normalization you can look at normalize  (aka normalize-audio on
some distributions) it has a --peak option.
> I wanna in first step detect MAX sample in whole WAV file.
> For example we gottaMAX sample 10 000, then Apmliefier_coefficient
> will be 32 000/10 000 = 3,2 .
> In second step i wanna trim silences at begin and below -80 dB [or 2
> bit noise]
> For this in same file each sample multiple by Apmliefier_coefficient ,
> and see - result is over -80 dB or not.
> If not, then first N samples will not written in trimmed file, but
> first sample that is over -80 dB [in any channel] ,
> and all further samples written in new file.
> Now we must just follow which sample [in any channel] is over -80 dB.
> After write is complete, we can just truncate after last sample that
> was over -80 dB, and write header.
> So far i have found SOX vanna reverse da file for end silence trim,
> and for each step produce tmp file.
> Is here C API , program, script, way to do so what without any
> temporary files ?
> I have written script for normalize, but what ir best way for normalize ?
> What about mp3 and ogg automatic normalize and frames trim ?
> Tnx in advance
> for i in *.wav; do
> echo "** Check peak for $i **"
> ampl=`sox "$i" -t wav /dev/null stat -v 2>&1`
> wert1="1.1"; wert2=$ampl;
> wahr=$(echo "$wert1 > $wert2" | bc)
> if [ $wahr = 1 ]; then
> echo " $wert1 > $wert2 , Do Nuthin"
> echo " $wert1 <= $wert2 , Do process"
> echo "** Amplifying volume by -=$ampl=- to fake a normalize
> $val.wav -- $waveaus"
> ampl2=$(echo $ampl*0.9995 | bc -l)
> echo "ampl2 = $ampl2"
> sox -v $ampl2 "$i" -t wav "$waveaus"
> echo ""
> Linux-audio-dev mailing list
> Linux-audio-dev at lists.linuxaudio.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Linux-audio-dev