Re: Program to modify RMS levels ("Summers, Walter V WRAMC-Wash DC" )


Subject: Re: Program to modify RMS levels
From:    "Summers, Walter V WRAMC-Wash DC"               <Walter.Summers(at)NA.AMEDD.ARMY.MIL>
Date:    Thu, 2 Aug 2001 08:29:44 -0400

This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C11B4E.CF2CE6F0 Content-Type: text/plain; charset="iso-8859-1" The matlab .m file listed below will take an input .wav file, scale the file up or down by x dB and write an output file .wav file. The routine will not produce an output file if scaling produces values > 1 or <-1 since these produce clipping in a .wav file For an input file named "truth.wav" you would get an output file, "truth-3.wav" scaled down by 3 dB with the syntax: change_wavefile_db('truth.wav','truth-3.wav',-3) Of course you should test the routine yourself before using it. Van Summers walter.summers(at)na.amedd.army.mil <mailto:walter.summers(at)na.amedd.army.mil> 202 782 8585 function change_wavefile_db(infile,outfile,dbchange) %change_wavefile_db(infile,outfile,dbchange) [origwave,fs,bits]=wavread(infile); orig_rmslin = sqrt(mean(origwave.^2)); orig_rmsdb = 20 .* log10(sqrt(mean(origwave.^2))) new_rmslin=10^((orig_rmsdb+dbchange)/20); newwave=origwave.*(new_rmslin/orig_rmslin); new_rmsdb = 20 .* log10(sqrt(mean(newwave.^2))) max_mag = max(abs(newwave)); if max_mag > 1 display('WITH SCALING MAX MAGNITUDE > 1, .WAV WOULD CLIP, NO OUTPUT FILE CREATED !!!') else wavwrite(newwave,fs,outfile); end -----Original Message----- From: Mitchell Sommers [mailto:msommers(at)ARTSCI.WUSTL.EDU] Sent: Wednesday, August 01, 2001 2:15 PM To: AUDITORY(at)LISTS.MCGILL.CA Subject: Program to modify RMS levels Does anyone know of software that will allow users to modify (specify) RMS levels. Ideally, it would accept .wav files but this is not a necessity. I have several hundred speech files that I'd like to equalize based on RMS levels so batch processing would be essential. Thanks in advance for any suggestions Mitchell S. Sommers, Ph.D. Associate Professor Department of Psychology Washington University Campus Box 1125 St. Louis, MO 63130 E-mail: msommers(at)artsci.wustl.edu <mailto:msommers(at)artsci.wustl.edu> Phone: 314-935-6561 Fax:: 314-935-7588 ------_=_NextPart_001_01C11B4E.CF2CE6F0 Content-Type: text/html; charset="iso-8859-1" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META content="MSHTML 5.50.4134.100" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffff00> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2>The matlab&nbsp;.m file&nbsp;listed below will take an input .wav file, scale the file up or down by x dB and write an output file .wav file.</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2>The routine will not produce an output file if scaling produces values &gt; 1 or &lt;-1 since these produce clipping in a .wav file</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2>For an input file named "truth.wav" you would get an output file, "truth-3.wav"&nbsp;scaled down by 3 dB&nbsp; with the syntax:</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2>change_wavefile_db('truth.wav','truth-3.wav',-3)</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2>Of course you should test the routine yourself before using it.</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2>Van Summers</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2><A href="mailto:walter.summers(at)na.amedd.army.mil">walter.summers(at)na.amedd.army.mil</A></FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2>202 782 8585</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" color=#0000ff size=2>function </FONT><FONT face="Courier New" size=2>change_wavefile_db(infile,outfile,dbchange)</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" color=#228b22 size=2>%change_wavefile_db(infile,outfile,dbchange)</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>[origwave,fs,bits]=wavread(infile);</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>orig_rmslin = sqrt(mean(origwave.^2));</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>orig_rmsdb = 20 .* log10(sqrt(mean(origwave.^2)))</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>new_rmslin=10^((orig_rmsdb+dbchange)/20);</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>newwave=origwave.*(new_rmslin/orig_rmslin);</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>new_rmsdb = 20 .* log10(sqrt(mean(newwave.^2)))</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>max_mag = max(abs(newwave));</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" color=#0000ff size=2>if </FONT><FONT face="Courier New" size=2>max_mag &gt; 1</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>display(</FONT><FONT face="Courier New" color=#b22222 size=2>'WITH SCALING MAX MAGNITUDE &gt; 1, .WAV WOULD CLIP, NO OUTPUT FILE CREATED !!!'</FONT><FONT face="Courier New" size=2>)</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" color=#0000ff size=2>else</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" size=2>wavwrite(newwave,fs,outfile);</FONT></SPAN></DIV> <DIV><SPAN class=330301812-02082001><FONT face="Courier New" color=#0000ff size=2>end</DIV></FONT><FONT face="Courier New" size=2></FONT></SPAN> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> Mitchell Sommers [mailto:msommers(at)ARTSCI.WUSTL.EDU]<BR><B>Sent:</B> Wednesday, August 01, 2001 2:15 PM<BR><B>To:</B> AUDITORY(at)LISTS.MCGILL.CA<BR><B>Subject:</B> Program to modify RMS levels<BR><BR></FONT></DIV> <DIV>Does anyone know of software that will allow users to modify (specify) RMS levels.&nbsp; Ideally, it would accept .wav files but this is not a necessity.&nbsp; I have several hundred speech files that I'd like to equalize based on RMS levels so batch processing would be essential.&nbsp; Thanks in advance for any suggestions</DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV> <DIV>Mitchell S. Sommers, Ph.D.<BR>Associate Professor<BR>Department of Psychology<BR>Washington University<BR>Campus Box 1125<BR>St. Louis, MO 63130</DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV> <DIV>E-mail: <A href="mailto:msommers(at)artsci.wustl.edu">msommers(at)artsci.wustl.edu</A><BR>Phone: 314-935-6561<BR>Fax::&nbsp; 314-935-7588</DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML> ------_=_NextPart_001_01C11B4E.CF2CE6F0--


This message came from the mail archive
http://www.auditory.org/postings/2001/
maintained by:
DAn Ellis <dpwe@ee.columbia.edu>
Electrical Engineering Dept., Columbia University