Skip to content

Commit d969d46

Browse files
authored
Add decibel level metric to dashboard (#296)
Addresses part of #292 Signed-off-by: Dave Thaler <[email protected]>
1 parent f00f023 commit d969d46

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

OrcanodeMonitor/Core/Fetcher.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ public async static Task UpdateManifestTimestampAsync(OrcanodeMonitorContext con
994994
if (frequencyInfo != null)
995995
{
996996
node.AudioStreamStatus = frequencyInfo.Status;
997+
node.DecibelLevel = frequencyInfo.GetMaxNonHumDecibels();
997998
}
998999
node.AudioStandardDeviation = 0.0;
9991000

OrcanodeMonitor/Core/FrequencyInfo.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ private double GetMaxNonHumMagnitude(Dictionary<double, double> frequencyMagnitu
241241
/// <returns>Magnitude</returns>
242242
public double GetMaxNonHumMagnitude(int? channel = null) => GetMaxNonHumMagnitude(GetFrequencyMagnitudes(channel));
243243

244+
/// <summary>
245+
/// Find the maximum decibels outside the audio hum range.
246+
/// </summary>
247+
/// <param name="channel">Channel, or null for all</param>
248+
/// <returns>Magnitude</returns>
249+
public double GetMaxNonHumDecibels(int? channel = null) => MagnitudeToDecibels(GetMaxNonHumMagnitude(channel));
250+
244251
/// <summary>
245252
/// Find the total magnitude outside the audio hum range among a given set of frequency magnitudes.
246253
/// </summary>

OrcanodeMonitor/Models/Orcanode.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public Orcanode()
6666
PartitionValue = 1;
6767
MezmoLogSize = 0;
6868
MezmoViewId = string.Empty;
69+
DecibelLevel = 0;
6970
}
7071

7172
#region persisted
@@ -175,6 +176,22 @@ public Orcanode()
175176

176177
public double? AudioStandardDeviation { get; set; }
177178

179+
/// <summary>
180+
/// Measure of volume.
181+
/// </summary>
182+
public double? DecibelLevel { get; set; }
183+
184+
public string DecibelLevelForDisplay {
185+
get
186+
{
187+
if (DecibelLevel == null || DecibelLevel == 0)
188+
{
189+
return "N/A";
190+
}
191+
return ((int)Math.Round(DecibelLevel ?? 0)).ToString();
192+
}
193+
}
194+
178195
/// <summary>
179196
/// Whether the node is visible on the orcasound website.
180197
/// </summary>

OrcanodeMonitor/Pages/Index.cshtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<th><a href="https://app.mezmo.com/313dbd82f3/logs/view" target="_blank">Mezmo</a></th>
2020
<th><a href="https://open.quiltdata.com/b/audio-orcasound-net/tree/" target="_blank">S3 Stream</a></th>
2121
<th>Up%</th>
22+
<th>dB</th>
2223
<th><a href="https://live.orcasound.net/listen" target="_blank">Orcasound</a></th>
2324
<th><a href="https://aifororcas2.azurewebsites.net/hydrophones" target="_blank">OrcaHello</a></th>
2425
</tr>
@@ -77,6 +78,9 @@
7778
@Model.GetUptimePercentage(item)%
7879
</a>
7980
</td>
81+
<td>
82+
@Html.DisplayFor(modelItem => item.DecibelLevelForDisplay)
83+
</td>
8084
@if (item.OrcasoundStatus == Models.OrcanodeOnlineStatus.Absent)
8185
{
8286
<td style="background-color: @Model.NodeOrcasoundBackgroundColor(item); color: @Model.NodeOrcasoundTextColor(item)">
@@ -165,6 +169,9 @@
165169
<li>
166170
<b>Up%</b>: Percentage of time the S3 Stream has been online over the past week.
167171
</li>
172+
<li>
173+
<b>dB</b>: Maximum decibels other than hum.
174+
</li>
168175
<li>
169176
<b>Orcasound Absent</b>: orcasound.net does not know about the node.
170177
</li>

0 commit comments

Comments
 (0)