2022-07-09 19:01:58 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// update copies the contents of one float slice into another
|
2022-09-14 00:58:05 +01:00
|
|
|
func update(s1 []float64, s2 []float64, sz int) {
|
2022-07-09 19:01:58 +01:00
|
|
|
for i := 0; i < sz; i++ {
|
|
|
|
s1[i] = s2[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// roundFloat rounds a float value to a given precision
|
2022-07-09 19:01:58 +01:00
|
|
|
func roundFloat(val float64, precision uint) float64 {
|
|
|
|
ratio := math.Pow(10, float64(precision))
|
|
|
|
return math.Round(val*ratio) / ratio
|
|
|
|
}
|
2022-07-10 23:08:14 +01:00
|
|
|
|
|
|
|
// convertLevel performs the necessary math for a channel level
|
2022-09-14 00:58:05 +01:00
|
|
|
func convertLevel(i float64) float64 {
|
2022-07-10 23:08:14 +01:00
|
|
|
if i > 0 {
|
2022-10-04 20:18:26 +01:00
|
|
|
val := 20 * math.Log10(i)
|
|
|
|
return roundFloat(val, 1)
|
2022-07-10 23:08:14 +01:00
|
|
|
}
|
|
|
|
return -200.0
|
|
|
|
}
|