]> git.sesse.net Git - nageru/blobdiff - db.h
Make some common decibel macros.
[nageru] / db.h
diff --git a/db.h b/db.h
new file mode 100644 (file)
index 0000000..53261ab
--- /dev/null
+++ b/db.h
@@ -0,0 +1,11 @@
+#ifndef _DB_H
+#define _DB_H 1
+
+// Utility routines for working with decibels.
+
+#include <math.h>
+
+static inline double from_db(double db) { return pow(10.0, db / 20.0); }
+static inline double to_db(double val) { return 20.0 * log10(val); }
+
+#endif  // !defined(_DB_H)