I did a search but only found answers related to excel.
Objective :
Calculate the difference between the original audio LUFS values and the user defined LUFS value. Both values are negative and I use an operation to calculate the difference between these two values, where all audio in which the subtraction result is less than -0.5 will be ignored.
Note:
1 – The original LUFS value is checked through the audio log;
2 – User defined LUFS value is received via parameter by powershell script.
Script:
Param(
[decimal]$env:_vLUF
)
[decimal]$userLUFS = $env:_vLUF
$results = " "
$location = "C:Users$env:usernameDesktopÁudios LUFS"
$logSaida = "C:Users$env:usernameDesktopLogs_LUFS"
$logMatches = Select-String -Path "C:Users$env:usernameDesktopLogs_LUFS*.*" -Pattern '(?<I>^ +I:) +(?<LUFS>.+)|(?<I>^Input Integrated:) +(?<LUFS>.+)' -List | Select-Object -Property FileName -ExpandProperty Matches
$results = foreach ($log in $logMatches) {
$pos = $log.Filename.IndexOf("_")
$leftPart = $log.Filename.Substring(0, $pos)
$rightPart = $log.Filename.Substring($pos+1)
$LUFS = $log.Groups | Where-Object { $_.Name -eq "LUFS" }
[PSCustomObject]@{
Música = $rightPart
LUFS = [decimal]$($LUFS.Value -replace " .*")
}
}
# COMMAND to the subtraction:
$results | Where-Object {( ($_.LUFS -($userLUFS)) -lt -0.5)} | Out-File $files
The problem:
When the original LUFS value is greater than the user defined LUFS value, the subtraction is done correctly, see below:
Original LUFS ($_.LUFS): -12.0
User defined LUFS ($userLUFS): -8.8
When the user defined value is greater than original LUFS value, the subtraction returns a positive value in the result
even though both values are negative, see below:
Original LUFS ($_.LUFS) : -8.8
User defined LUFS ($userLUFS): -12.0
It seems that because the values are negative, it considers -8.8 GREATER than -12.0 because it is closer to 0.0, but what I want is that the result, regardless of the order of values received, always returns a negative result. I’ve tried multiplying the result by -1, but it just reverses the problem. How can I make the results always return with negative values?