Community Forums Archive

Go Back

Subject:Normalize based on RMS Scan
Posted by: broodley
Date:8/21/2008 5:08:19 PM

Hi all,
I'm trying to set up a script to Scan a batch of files, and only normalize those about a certain RMS threshold. Started poking around a bit in the script, but can't figure out how to pass the value of the scan as a variable to tell the script to only normalize on those conditions. Thanks for any help!

Subject:RE: Normalize based on RMS Scan
Reply by: _TJ
Date:8/26/2008 1:36:21 PM

the sample script statistics.cs shows you how to get the scan for the RMS level of a file.

The basic code looks like this (note that this is a code fragment not a full script).


ISfFileHost file = app.CurrentFile;

file.UpdateStatistics(null);
file.WaitForDoneOrCancel();

// normalize only if RMS level is less than this. (in dB
double dRMSNeedToNormalize_dB = -16.0;

// get highest RMS level (as a ratio, not as dB)
double dRMSMax = 0;
double dRMSMax_dB = 1.0;

if (file.StatisticsAreUpToDate)
{
for (uint ii = 0; ii < file.Channels; ++ii)
{
dRMSMax = Math.Max(dRMSMax, file.GetStatistics(ii).RMSLevel);
}
}
dRMSMax_dB = SfHelpers.RatioTodB(dRMSMax);

DPF("Max RMS {0} ({1} dB)", dRMSMax, dRMSMax_dB);

if (dRMSMax_dB >= dRMSNeedToNormalize_dB)
{
// "No need to normalize"
}
else
{
// "Normalize needed"
}



Go Back