mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
examples/pcm: Bug fix: build error
This commit is contained in:
parent
56f4968e70
commit
e43493fc4e
@ -93,6 +93,15 @@ func toBytes(l, r []int16) []byte {
|
||||
return b
|
||||
}
|
||||
|
||||
type srcStream struct {
|
||||
*bytes.Reader
|
||||
}
|
||||
|
||||
func (s *srcStream) Close() error {
|
||||
s.Reader = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func addNote() error {
|
||||
size := sampleRate / ebiten.FPS
|
||||
notes := []float64{freqC, freqD, freqE, freqF, freqG, freqA * 2, freqB * 2}
|
||||
@ -122,7 +131,8 @@ func addNote() error {
|
||||
square(l, vol, freq, 0.25)
|
||||
square(r, vol, freq, 0.25)
|
||||
b := toBytes(l, r)
|
||||
p, err := audioContext.NewPlayer(bytes.NewReader(b))
|
||||
s := &srcStream{bytes.NewReader(b)}
|
||||
p, err := audioContext.NewPlayer(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ type stream struct {
|
||||
}
|
||||
|
||||
func (s *stream) Close() error {
|
||||
s.Reader = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user