From 6ab577c85349c8d180b8e52ba3756a15caf620ba Mon Sep 17 00:00:00 2001 From: Dave Thaler Date: Sat, 21 Dec 2024 10:39:12 -0800 Subject: [PATCH] Add silent as an S3 stream status Signed-off-by: Dave Thaler --- OrcanodeMonitor/Core/FfmpegCoreAnalyzer.cs | 8 ++++---- OrcanodeMonitor/Models/Orcanode.cs | 1 + OrcanodeMonitor/Pages/Index.cshtml | 3 +++ Test/UnintelligibilityTests.cs | 13 +++++++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/OrcanodeMonitor/Core/FfmpegCoreAnalyzer.cs b/OrcanodeMonitor/Core/FfmpegCoreAnalyzer.cs index 5bf41d2..010081c 100644 --- a/OrcanodeMonitor/Core/FfmpegCoreAnalyzer.cs +++ b/OrcanodeMonitor/Core/FfmpegCoreAnalyzer.cs @@ -88,14 +88,14 @@ private static FrequencyInfo AnalyzeFrequencies(float[] data, int sampleRate, Or if (max < MinNoiseAmplitude) { // File contains mostly silence across all frequencies. - frequencyInfo.Status = OrcanodeOnlineStatus.Unintelligible; + frequencyInfo.Status = OrcanodeOnlineStatus.Silent; return frequencyInfo; } - if ((max <= MaxSilenceAmplitude) && (oldStatus == OrcanodeOnlineStatus.Unintelligible)) + if ((max <= MaxSilenceAmplitude) && (oldStatus == OrcanodeOnlineStatus.Silent)) { - // In between the min and max unintelligibility range, so keep previous status. - frequencyInfo.Status = OrcanodeOnlineStatus.Unintelligible; + // In between the min and max silence range, so keep previous status. + frequencyInfo.Status = oldStatus; return frequencyInfo; } diff --git a/OrcanodeMonitor/Models/Orcanode.cs b/OrcanodeMonitor/Models/Orcanode.cs index 5ebce09..d7c9607 100644 --- a/OrcanodeMonitor/Models/Orcanode.cs +++ b/OrcanodeMonitor/Models/Orcanode.cs @@ -20,6 +20,7 @@ public enum OrcanodeOnlineStatus Hidden, Unauthorized, NoView, + Silent, } public enum OrcanodeUpgradeStatus { diff --git a/OrcanodeMonitor/Pages/Index.cshtml b/OrcanodeMonitor/Pages/Index.cshtml index 374bb5f..2201ed4 100644 --- a/OrcanodeMonitor/Pages/Index.cshtml +++ b/OrcanodeMonitor/Pages/Index.cshtml @@ -153,6 +153,9 @@
  • S3 Stream Online: Audio stream is working normally.
  • +
  • + S3 Stream Silent: Audio stream contains silence. +
  • S3 Stream Unauthorized: Access denied when trying to check the audio stream.
  • diff --git a/Test/UnintelligibilityTests.cs b/Test/UnintelligibilityTests.cs index 855c9a0..12ca62d 100644 --- a/Test/UnintelligibilityTests.cs +++ b/Test/UnintelligibilityTests.cs @@ -36,12 +36,17 @@ private async Task TestSampleAsync(string filename, OrcanodeOnlineStatus expecte } } + [TestMethod] + public async Task TestSilentSample() + { + await TestSampleAsync("unintelligible\\live1791.ts", OrcanodeOnlineStatus.Silent); + } + [TestMethod] public async Task TestUnintelligibleSample() { await TestSampleAsync("unintelligible\\live4869.ts", OrcanodeOnlineStatus.Unintelligible); await TestSampleAsync("unintelligible\\live1816b.ts", OrcanodeOnlineStatus.Unintelligible); - await TestSampleAsync("unintelligible\\live1791.ts", OrcanodeOnlineStatus.Unintelligible); await TestSampleAsync("unintelligible\\live1815.ts", OrcanodeOnlineStatus.Unintelligible); await TestSampleAsync("unintelligible\\live1816.ts", OrcanodeOnlineStatus.Unintelligible); } @@ -61,11 +66,11 @@ public async Task TestNormalSample() public async Task TestHysteresisBehavior() { // Bush Point file from arond 5pm 11/18/2024 is relatively quiet (max amplitude 17.46). - // Test state retention when transitioning from Online to borderline Unintelligible. + // Test state retention when transitioning from Online to borderline Silent. await TestSampleAsync("normal/live6079.ts", OrcanodeOnlineStatus.Online, OrcanodeOnlineStatus.Online); - // Test state retention when transitioning from Unintelligible to borderline Online. - await TestSampleAsync("normal/live6079.ts", OrcanodeOnlineStatus.Unintelligible, OrcanodeOnlineStatus.Unintelligible); + // Test state retention when transitioning from Silent to borderline Online. + await TestSampleAsync("normal/live6079.ts", OrcanodeOnlineStatus.Silent, OrcanodeOnlineStatus.Silent); // Test clear state changes (should override hysteresis). await TestSampleAsync("unintelligible/live4869.ts", OrcanodeOnlineStatus.Unintelligible, OrcanodeOnlineStatus.Online);