fix bounds check

This commit is contained in:
Christopher Cooper 2017-07-05 18:15:53 -04:00
parent 6dd3a9a643
commit f542f75202
1 changed files with 1 additions and 6 deletions

View File

@ -5,8 +5,6 @@ import (
"fmt" "fmt"
"os"
"github.com/faiface/pixel/audio" "github.com/faiface/pixel/audio"
) )
@ -17,10 +15,7 @@ type sine struct {
} }
func (s *sine) Stream(samples [][2]float64) (n int, ok bool) { func (s *sine) Stream(samples [][2]float64) (n int, ok bool) {
if len(samples) == 0 { for i := 0; i < len(samples)-1; i += 2 {
os.Exit(-1)
}
for i := 0; i < len(samples)-2; i += 2 {
val := math.Sin(math.Pi*s.time*s.freq) / 1.1 val := math.Sin(math.Pi*s.time*s.freq) / 1.1
s.time += 1 / s.rate s.time += 1 / s.rate
valI := int16((1 << 15) * val) valI := int16((1 << 15) * val)