From d3ca7dbf6c56790f9a3d74c12da49dc61e5111e1 Mon Sep 17 00:00:00 2001
From: DJ2LS <75909252+DJ2LS@users.noreply.github.com>
Date: Fri, 18 Nov 2022 14:23:13 +0100
Subject: [PATCH] moved from rms to dbFS
---
gui/src/index.html | 4 ++--
tnc/modem.py | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/gui/src/index.html b/gui/src/index.html
index d0000a4d..35c272f9 100644
--- a/gui/src/index.html
+++ b/gui/src/index.html
@@ -770,8 +770,8 @@
-
-
RX AUDIO LEVEL
+
+
-dBFS
diff --git a/tnc/modem.py b/tnc/modem.py
index 3db2cda9..6dd3d436 100644
--- a/tnc/modem.py
+++ b/tnc/modem.py
@@ -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