summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-02-27 22:26:57 +0100
committerCarl Hetherington <cth@carlh.net>2020-02-27 22:26:57 +0100
commitbcc4e2f7dc4cd5658e199ddacb7202b00ec72cf1 (patch)
tree70a6d59908b1d1391e2f9ecd2c8bd17890b3bbc5 /src/lib/util.cc
parenta2ceaa313a2b8ba28516c935f7f8b82d69957b77 (diff)
Add and use dB/linear conversion functions.
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index bbb444367..e4f552c4d 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -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);
+}
+