Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Institute of Technical Acoustics (ITA)
ITABase
Commits
9b818c58
Commit
9b818c58
authored
Nov 13, 2016
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nicer ration to db20
parent
13249b91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
src/ITANumericUtils.cpp
src/ITANumericUtils.cpp
+9
-3
No files found.
src/ITANumericUtils.cpp
View file @
9b818c58
...
...
@@ -132,9 +132,15 @@ double db20_to_ratio(double db) {
return
(
db
==
DECIBEL_MINUS_INFINITY
?
0
:
pow
(
10
,
db
/
20.0
));
}
double
ratio_to_db20
(
double
r
)
{
if
(
r
<
0
)
ITA_EXCEPT0
(
INVALID_PARAMETER
);
return
(
r
==
0
?
DECIBEL_MINUS_INFINITY
:
20
*
log10
(
r
));
double
ratio_to_db20
(
double
r
)
{
if
(
r
<
0.0
f
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Conversion to decibel not possible for negative values"
);
if
(
r
==
0.0
f
)
return
DECIBEL_MINUS_INFINITY
;
else
return
20.0
f
*
log10
(
r
);
}
/* +------------------------------------+
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment