Skip to content

Commit

Permalink
audio level
Browse files Browse the repository at this point in the history
  • Loading branch information
dsokolov committed Feb 2, 2017
1 parent 4acfd5d commit d8408ed
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions rxaa/src/main/kotlin/me/ilich/rxandroidaudio/AudioLevel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@ class AudioLevel {
map { sh ->
sh.toDouble() / Short.MAX_VALUE
}.
map { db ->
if (db == 0.0) {
EPSILON
} else {
Math.abs(db)
}
}.
map { db ->
20.0 * Math.log10(db)
}.
filter { it == 0.0 }.
map { Math.abs(it) }.
map { 20.0 * Math.log10(it) }.
filter(Double::isFinite).
max() ?:
Double.NEGATIVE_INFINITY
Expand Down

0 comments on commit d8408ed

Please sign in to comment.