moved from rms to dbFS

This commit is contained in:
DJ2LS 2022-11-18 14:23:13 +01:00
parent 4c18a843fc
commit d3ca7dbf6c
2 changed files with 7 additions and 3 deletions

View file

@ -770,8 +770,8 @@
</div>
<div class="card-body p-2">
<div class="progress mb-0" style="height: 15px;">
<div class="progress-bar progress-bar-striped bg-primary" id="rms_level" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
<p class="justify-content-center d-flex position-absolute w-100">RX AUDIO LEVEL</p>
<div class="progress-bar progress-bar-striped bg-primary" id="rms_level" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="-50" aria-valuemax="0"></div>
<p class="justify-content-center d-flex position-absolute w-100">-dBFS</p>
</div>
<div class="progress mb-0" style="height: 5px;">
<div class="progress-bar progress-bar-striped bg-warning" role="progressbar" style="width: 1%" aria-valuenow="1" aria-valuemin="0" aria-valuemax="100"></div>

View file

@ -882,7 +882,11 @@ class RF:
rms_counter += 1
if rms_counter > 50:
d = np.frombuffer(self.fft_data, np.int16).astype(np.float)
static.AUDIO_RMS = int(np.sqrt(np.mean(d ** 2)))
# calculate RMS and then dBFS
# TODO: Need to change static.AUDIO_RMS to AUDIO_DBFS somewhen
rms = int(np.sqrt(np.mean(d ** 2)))
static.AUDIO_RMS = 20 * np.log10(rms * np.sqrt(2) / 32768)
rms_counter = 0
# Convert data to int to decrease size