From cbc0c6f7990d6908fc2f0fecfe8ab876c7172a76 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@msavard.(none)>
Date: Mon, 13 Feb 2012 00:29:49 -0500
Subject: [PATCH] #8672: Add linear to decibel conversion functions in audio
 layer

---
 daemon/src/audio/audiolayer.h | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/daemon/src/audio/audiolayer.h b/daemon/src/audio/audiolayer.h
index 3a52b96a19..f095bd1180 100644
--- a/daemon/src/audio/audiolayer.h
+++ b/daemon/src/audio/audiolayer.h
@@ -109,7 +109,21 @@ class AudioLayer {
          * Apply gain to audio frame
          */
         static void applyGain(SFLDataFormat *src , int samples, int gain);
-        
+
+        /**
+         * Convert audio amplitude value from linear value to dB
+         */
+        static double amplitudeLinearToDB(double value) {
+            return 20.0 * log10(value);
+        }
+
+        /**
+         * Convert audio amplitude from dB to Linear value
+         */
+        static double ampluitudeDBToLinear(double value) {
+            return pow(10.0, value / 20.0);
+        }
+ 
         /**
          * Set capture stream gain (microphone)
          */
-- 
GitLab