initial commit

add internal/xair module
This commit is contained in:
2026-01-30 22:42:11 +00:00
commit 4a6ace0fdf
13 changed files with 885 additions and 0 deletions

42
internal/xair/util.go Normal file
View File

@@ -0,0 +1,42 @@
package xair
import "math"
func mustDbInto(db float64) float64 {
switch {
case db >= 10:
return 1
case db >= -10:
return float64((db + 30) / 40)
case db >= -30:
return float64((db + 50) / 80)
case db >= -60:
return float64((db + 70) / 160)
case db >= -90:
return float64((db + 90) / 480)
default:
return 0
}
}
func mustDbFrom(level float64) float64 {
switch {
case level >= 1:
return 10
case level >= 0.5:
return toFixed(float64(level*40)-30, 1)
case level >= 0.25:
return toFixed(float64(level*80)-50, 1)
case level >= 0.0625:
return toFixed(float64(level*160)-70, 1)
case level >= 0:
return toFixed(float64(level*480)-90, 1)
default:
return -90
}
}
func toFixed(num float64, precision int) float64 {
output := math.Pow(10, float64(precision))
return float64(math.Round(num*output)) / output
}