Hi experts.<br /><br />I have started my small project - mp3 database for radio.<br />http://martini.pudele.com/radio/mp3_database/mp3_database.html<br /><div id="sig_upper"><br />How do i normalize by peak [not RMS] and trim silences in begin and end of WAV files ?<br />Silences somewhere in middle of file i wanna leave untouched.<br /><br /><span lang="en" class="short_text" id="result_box"><span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">I wanna in first step detect MAX sample in whole WAV file.<br /></span></span> For example we gotta<span lang="en" class="short_text" id="result_box"><span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken"> MAX sample 10 000, then Apmliefier_coefficient will be 32 000/10 000 = 3,2 .</span></span><br /><br />In second step i wanna trim silences at begin and below -80 dB [or 2 bit noise]<br /> For this in same file each sample multiple by <span lang="en" class="short_text" id="result_box"><span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">Apmliefier_coefficient , and see - resul</span></span>t is over  -80 dB or not.<br />If not, then first N samples will not written in trimmed file, but first sample that is over  -80 dB [in any channel] ,<br />and all further samples written in new file.<br />Now we must just follow which sample  [in any channel] is  over  -80 dB.<br />After write is complete, we can just truncate after last sample that was  over  -80 dB, and write header.<br /><br />  <br />So far i have found SOX vanna reverse da file for end silence trim, and for each step produce tmp file.<br /><br />  Is here C API , program, script, way to do so what without any temporary files ? <br /><br />I have written script for normalize, but what ir best way for normalize ?<br />What about mp3 and ogg  automatic normalize and frames trim ?<br /><br />Tnx in advance<br />Alf<br /><br />====<br /><br />#!/bin/bash<br /><br />for i in *.wav; do<br /><br /> val=${i%.wav}<br /> echo "** Check peak for $i **"<br /><br />  ampl=`sox "$i" -t wav /dev/null stat -v 2>&1`<br />  waveaus=${i%.wav}.wave<br /><br />  wert1="1.1";  wert2=$ampl;<br />  wahr=$(echo  "$wert1 >  $wert2" | bc)<br />  if  [ $wahr = 1 ]; then<br />    echo "  $wert1 > $wert2 , Do Nuthin"<br />  else<br />    echo "  $wert1 <= $wert2 , Do process"<br />    echo "** Amplifying volume by  -=$ampl=-  to fake a normalize   $val.wav  --  $waveaus"<br />    ampl2=$(echo $ampl*0.9995 | bc -l)<br />    echo "ampl2 = $ampl2"<br />    sox -v $ampl2  "$i"  -t wav  "$waveaus"<br />  fi<br /><br />echo ""<br /><br />done<br /><br /><br />  <br /> ----</div><br /> <div id="sig_lower"> </div>
<!--                                                                                                                                                                                                                                                                                                                      -->