mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +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
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type srcStream struct {
|
||||||
|
*bytes.Reader
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *srcStream) Close() error {
|
||||||
|
s.Reader = nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func addNote() error {
|
func addNote() error {
|
||||||
size := sampleRate / ebiten.FPS
|
size := sampleRate / ebiten.FPS
|
||||||
notes := []float64{freqC, freqD, freqE, freqF, freqG, freqA * 2, freqB * 2}
|
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(l, vol, freq, 0.25)
|
||||||
square(r, vol, freq, 0.25)
|
square(r, vol, freq, 0.25)
|
||||||
b := toBytes(l, r)
|
b := toBytes(l, r)
|
||||||
p, err := audioContext.NewPlayer(bytes.NewReader(b))
|
s := &srcStream{bytes.NewReader(b)}
|
||||||
|
p, err := audioContext.NewPlayer(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,7 @@ type stream struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *stream) Close() error {
|
func (s *stream) Close() error {
|
||||||
|
s.Reader = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user