From bf33ec93a4c44bd075f95572d84087e301b3a0b9 Mon Sep 17 00:00:00 2001 From: Mikolaj Date: Fri, 4 Aug 2023 15:21:44 +0200 Subject: [PATCH] Fix visibility modifiers & add comment to calculateValue --- .../membraneframework/rtc/media/SoundDetection.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MembraneRTC/src/main/java/org/membraneframework/rtc/media/SoundDetection.java b/MembraneRTC/src/main/java/org/membraneframework/rtc/media/SoundDetection.java index 30096f3..f5c980b 100644 --- a/MembraneRTC/src/main/java/org/membraneframework/rtc/media/SoundDetection.java +++ b/MembraneRTC/src/main/java/org/membraneframework/rtc/media/SoundDetection.java @@ -60,7 +60,7 @@ public void setSoundDetectionListener(OnSoundDetectedListener listener) { onSoundDetectedListener = listener; } - public void setIsSoundDetected(boolean newValue) { + private void setIsSoundDetected(boolean newValue) { if (onSoundDetectedListener != null) { onSoundDetectedListener.onSoundDetected(newValue); } @@ -77,7 +77,13 @@ private int getMaxAmplitude(short[] buffer, int bytesRead) { } return maxAmplitude; } - + /** + * Calculates the sound level value in decibels (dB) based on the given maxAmplitude. + * If maxAmplitude is non-positive (<= 0), returns a default value of -160 dB. + * Otherwise, computes the value using the formula: 20 * log10(maxAmplitude / 32767), + * where 32767 is the maximum value for a 16-bit PCM audio sample. + * The calculated dB value represents the loudness of the audio signal. + **/ private int calculateValue(int maxAmplitude) { if (maxAmplitude <= 0) { return -160;