Add and use dB/linear conversion functions.
[dcpomatic.git] / src / lib / util.cc
index bbb44436713281d5a3a88ee0bec5a265bd2e6efa..e4f552c4d7c46177414b1db0e40352847f7bf705 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -1171,3 +1171,16 @@ write_swaroop_chain (shared_ptr<const dcp::CertificateChain> chain, boost::files
 }
 
 #endif
+
+double
+db_to_linear (double db)
+{
+       return pow(10, db / 20);
+}
+
+double
+linear_to_db (double linear)
+{
+       return 20 * log10(linear);
+}
+