Skip to content

Commit 6a1394d

Browse files
Alextophermalparty
andauthored
Update generators/triangle.go
Co-authored-by: Xavier MALPARTY <[email protected]>
1 parent e401174 commit 6a1394d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

generators/triangle.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ func TriangleTone(sr beep.SampleRate, freq float64) (beep.Streamer, error) {
2828
func (g *triangleGenerator) Stream(samples [][2]float64) (n int, ok bool) {
2929
for i := range samples {
3030
if g.t < 0.5 {
31-
samples[i][0] = 2.0 * g.t
32-
samples[i][1] = 2.0 * g.t
31+
samples[i][0] = 2.0*(1-g.t) - 1
32+
samples[i][1] = 2.0*(1-g.t) - 1
3333
} else {
34-
samples[i][0] = 2.0 * (1.0 - g.t)
35-
samples[i][1] = 2.0 * (1.0 - g.t)
34+
samples[i][0] = 2.0*g.t - 1.0
35+
samples[i][1] = 2.0*g.t - 1.0
3636
}
3737
_, g.t = math.Modf(g.t + g.dt)
3838
}

0 commit comments

Comments
 (0)