moved from sum to mean

This commit is contained in:
dj2ls 2022-10-12 12:33:35 +02:00
parent 7d2168a0e7
commit 392e0bf930

View file

@ -877,11 +877,11 @@ class RF:
# Calculate audio RMS # Calculate audio RMS
# https://stackoverflow.com/a/9763652 # https://stackoverflow.com/a/9763652
# calculate RMS every 150 cycles for reducing CPU load # calculate RMS every 50 cycles for reducing CPU load
rms_counter += 1 rms_counter += 1
if rms_counter > 150: if rms_counter > 50:
d = np.frombuffer(self.fft_data, np.int16).astype(np.float) d = np.frombuffer(self.fft_data, np.int16).astype(np.float)
static.AUDIO_RMS = int(np.sqrt((d * d).sum() / len(d))) static.AUDIO_RMS = int(np.sqrt(np.mean(d ** 2)))
rms_counter = 0 rms_counter = 0
# Check for signals higher than average by checking for "100" # Check for signals higher than average by checking for "100"