Files
wehub-resource-sync ead81af521
Deploy to GitHub Pages / deploy (push) Failing after 0s
CI / go (push) Has been cancelled
CI / build (darwin, macos-14) (push) Has been cancelled
CI / build (windows, windows-2025) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:13 +08:00

28 lines
352 B
Go

package mediactl
import "math"
func dbToLinear(db float64) float64 {
if db <= -30 {
return 0.0
}
if db >= 6 {
return 1.0
}
return math.Pow(10, db/20) / math.Pow(10, 6.0/20)
}
func linearToDb(v float64) float64 {
if v <= 0 {
return -30
}
if v >= 1 {
return 6
}
db := 20*math.Log10(v) + 6
if db < -30 {
return -30
}
return db
}