Skip to content

Commit

Permalink
[server] lets try a simpler and hopefully less buggy Normalize() impl
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowsink committed Nov 4, 2023
1 parent 1b76c31 commit 6366e54
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion UwuRadio.Server/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ public static Constants
/// <summary>
/// The target Integrated LUFS
/// </summary>
public string AudioNormIntegrated { get; set; } = null!;
public double AudioNormIntegrated { get; set; }
}
5 changes: 4 additions & 1 deletion UwuRadio.Server/DSP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ public static async Task<LoudnessMeasurement> MeasureLoudness(string path)

public static async Task Normalize(string inPath, string outPath, LoudnessMeasurement measurement)
{
var lufsLoudnessChange = Constants.C.AudioNormIntegrated - measurement.IntegratedLoudness;
var clampedLoudnessChange = Math.Min(lufsLoudnessChange, -measurement.TruePeak);

var args = new List<string> { "-nostdin", "-i", inPath, "-filter:a",
$"loudnorm=measured_i={measurement.IntegratedLoudness}:measured_thresh={measurement.IntegratedThreshold}:measured_lra={measurement.LoudnessRange}:measured_tp={measurement.TruePeak}:i={Constants.C.AudioNormIntegrated}",
$"volume={clampedLoudnessChange}dB",
"-f", Constants.C.AudioFormat
};

Expand Down
2 changes: 1 addition & 1 deletion UwuRadio.Server/constants.debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"IngestFolder": "../ingest",
"AudioFormat": "mp3",
"AudioQScale": "6",
"AudioNormIntegrated": "-16"
"AudioNormIntegrated": -16
}
2 changes: 1 addition & 1 deletion UwuRadio.Server/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"IngestFolder": "ingest",
"AudioFormat": "mp3",
"AudioQScale": "6",
"AudioNormIntegrated": "-16"
"AudioNormIntegrated": -16
}

0 comments on commit 6366e54

Please sign in to comment.