-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutil.go
35 lines (30 loc) · 774 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package voicemeeter
import "math"
// allTrue accepts a boolean slice and evaluates if all elements are True
func allTrue(s []bool, sz int) bool {
for i := 0; i < sz; i++ {
if !s[i] {
return false
}
}
return true
}
// update copies the contents of one float slice into another
func update(s1 []float64, s2 []float64, sz int) {
for i := 0; i < sz; i++ {
s1[i] = s2[i]
}
}
// roundFloat rounds a float value to a given precision
func roundFloat(val float64, precision uint) float64 {
ratio := math.Pow(10, float64(precision))
return math.Round(val*ratio) / ratio
}
// convertLevel performs the necessary math for a channel level
func convertLevel(i float64) float64 {
if i > 0 {
val := 20 * math.Log10(i)
return roundFloat(val, 1)
}
return -200.0
}