@@ -18,13 +18,11 @@ func (o *Oscillator) NextSample() (v float64) {
18
18
return
19
19
}
20
20
21
- const volume = 0.7
22
-
23
21
func Triangle (pos float64 ) float64 {
24
22
phase := math .Mod (pos , 1 )
25
23
value := math .Abs (phase * 2 - 1 )* 2 - 1
26
24
27
- return value * volume
25
+ return value * 0.45
28
26
}
29
27
30
28
func TiltedSaw (pos float64 ) float64 {
@@ -35,12 +33,12 @@ func TiltedSaw(pos float64) float64 {
35
33
} else {
36
34
v = (1 - phase ) * 16
37
35
}
38
- return (v - 1 ) * volume
36
+ return (v - 1 ) * 0.45
39
37
}
40
38
41
39
func Saw (pos float64 ) float64 {
42
40
phase := math .Mod (pos , 1 )
43
- return (phase - 0.5 ) * 0.9
41
+ return (phase - 0.5 ) * 0.65
44
42
}
45
43
46
44
func Square (pos float64 ) float64 {
@@ -49,7 +47,7 @@ func Square(pos float64) float64 {
49
47
if phase < 0.5 {
50
48
v = 1.0
51
49
}
52
- return v / 3 .0
50
+ return v / 4 .0
53
51
}
54
52
55
53
func Pulse (pos float64 ) float64 {
@@ -58,13 +56,15 @@ func Pulse(pos float64) float64 {
58
56
if phase < 0.3125 {
59
57
v = 1.0
60
58
}
61
- return v / 3 .0
59
+ return v / 4 .0
62
60
}
63
61
64
62
// Organ is triangle / 2
65
63
func Organ (pos float64 ) float64 {
66
64
pos = pos * 4
67
65
68
- return (math .Abs (math .Mod (pos , 2 )- 1 ) - 0.5 +
69
- (math .Abs ((math .Mod (pos * 0.5 , 2 ))- 1 )- 0.5 )/ 2 - 0.1 ) * volume
66
+ v := math .Abs (math .Mod (pos , 2 )- 1 ) - 0.5 +
67
+ (math .Abs ((math .Mod (pos * 0.5 , 2 ))- 1 )- 0.5 )/ 2 - 0.1
68
+
69
+ return v * 0.55
70
70
}
0 commit comments