[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Program to modify RMS levels



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@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@ARTSCI.WUSTL.EDU]
Sent: Wednesday, August 01, 2001 2:15 PM
To: AUDITORY@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@artsci.wustl.edu
Phone: 314-935-6561
Fax::  314-935-7588