Level file operations (Loudness)
Magnetron can measure and correct raw uncompressed audio files to the ATSC and EBU R128 loudness standard.
Note: with both functions there is also a callback function to track the progress.
- levelFileAnalyse
- Takes an audio file (wav/aiff/flac) and analyses it
- levelFileProcess
- Corrects a file to the properties provided. Takes an audio file (wav/aiff/flac) and adjusts it to target and limiter settings
example
// loads a audio file (wav,aiff,flac,mp3,ogg,wma) and writes a R128 corrected file (wav,aiff,flac)
function TestLevel()
{
var infile = openFileDialog("Select a file to normalize...", folders.home, "*.wav;*.aiff;*.flac;*.mp3;*.ogg;*.wma");
if (infile.length > 0)
{ // the levelapi settings to analyse
var settings = {};
settings["AdjustTargetType"] = "LU";
settings["AdjustTargetLevel"] = 0.;
settings["RelativeGate"] = -10.;
settings["DialogGate"] = false;
settings["CalibrationLU"] = -23.0;
var properties = levelFileAnalyse(infile, settings); // properties will contain all levels
echo(objectToString(properties));
/* these levels are needed as adjust parameter and could also be set manually
properties["AdjustLevel_NoLimit"] = 0.;
properties["NeedLimiting"] = true;
properties["LimitThresholddB"] = -1.;
*/
var outfile = saveFileDialog("Save file to...", folders.home, "*.wav;*.aiff;*.flac;*.mp3;*.ogg;*.wma");
if (outfile.length > 0)
levelFileProcess(infile, outfile, properties);
}
}
// this function is called when levelFileAnalyse is busy as part of TestLevel()
function LevelFileAnalyse_Progress(file, progress)
{
setProgress(50 * progress); // progress 0. to 1.
}
// this function is called when levelFileProcess is busy as part of TestLevel()
function LevelFileProcess_Progress(file, progress)
{
setProgress(50 + (50 * progress)); // progress 0. to 1.
}