Skip to content

Commit

Permalink
Add silent as an S3 stream status
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler committed Dec 21, 2024
1 parent 90f2816 commit 6ab577c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions OrcanodeMonitor/Core/FfmpegCoreAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions OrcanodeMonitor/Models/Orcanode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum OrcanodeOnlineStatus
Hidden,
Unauthorized,
NoView,
Silent,
}
public enum OrcanodeUpgradeStatus
{
Expand Down
3 changes: 3 additions & 0 deletions OrcanodeMonitor/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@
<li>
<b>S3 Stream Online</b>: Audio stream is working normally.
</li>
<li>
<b>S3 Stream Silent</b>: Audio stream contains silence.
</li>
<li>
<b>S3 Stream Unauthorized</b>: Access denied when trying to check the audio stream.
</li>
Expand Down
13 changes: 9 additions & 4 deletions Test/UnintelligibilityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down

0 comments on commit 6ab577c

Please sign in to comment.