music - profiles.go
1 package music
2
3 import "math"
4
5 type Profile func(pos float64) float64
6
7 func Steady(_ float64) float64 {
8 return 1
9 }
10
11 func Adjust(amount float64) Profile {
12 return func(_ float64) float64 {
13 return amount
14 }
15 }
16
17 func AdjustProfile(amount float64, p Profile) Profile {
18 return func(pos float64) float64 {
19 return amount * p(pos)
20 }
21 }
22
23 func RampUp(pos float64) float64 {
24 return pos
25 }
26
27 func RampDown(pos float64) float64 {
28 return 1 - pos
29 }
30
31 func ExponentialUp(pos float64) float64 {
32 return math.Pow(math.E, 6*(pos-1))
33 }
34
35 func ExponentialDown(pos float64) float64 {
36 return math.Pow(math.E, -6*pos)
37 }
38
39 func InverseExponentialUp(pos float64) float64 {
40 return 1 - ExponentialDown(pos)
41 }
42
43 func InverseExponentialDown(pos float64) float64 {
44 return 1 - ExponentialUp(pos)
45 }