Hello, I'm from the IKEMEN-Go project. On our save-state branch, we are having an issue where setting the ctrl.Streamer instance to nilisn't stopping sound. Setting ctrl.Paused = true stops the sound, though. Any suggestions as to what could be wrong and how to pin down this issue? Here is the code in our library:
Our custom streamer for handling Panning and Volume
type SoundEffect struct {
streamer beep.Streamer
volume float32
ls, p float32
x *float32
}
// sys is our global Game object
func (s *SoundEffect) Stream(samples [][2]float64) (n int, ok bool) {
lv, rv := s.volume, s.volume
if sys.stereoEffects && (s.x != nil || s.p != 0) {
var r float32
if s.x != nil { // pan
r = ((sys.xmax - s.ls**s.x) - s.p) / (sys.xmax - sys.xmin)
} else { // abspan
r = ((sys.xmax-sys.xmin)/2 - s.p) / (sys.xmax - sys.xmin)
}
sc := sys.panningRange / 100
of := (100 - sys.panningRange) / 200
lv = s.volume * 2 * (r*sc + of)
rv = s.volume * 2 * ((1-r)*sc + of)
if lv > 512 {
lv = 512
} else if lv < 0 {
lv = 0
}
if rv > 512 {
rv = 512
} else if rv < 0 {
rv = 0
}
}
n, ok = s.streamer.Stream(samples)
for i := range samples[:n] {
samples[i][0] *= float64(lv / 256)
samples[i][1] *= float64(rv / 256)
}
return n, ok
}
func (s *SoundEffect) Err() error {
return s.streamer.Err()
}
Hello, I'm from the IKEMEN-Go project. On our save-state branch, we are having an issue where setting the
ctrl.Streamer
instance tonil
isn't stopping sound. Settingctrl.Paused = true
stops the sound, though. Any suggestions as to what could be wrong and how to pin down this issue? Here is the code in our library:Our custom streamer for handling Panning and Volume
How we play sound
How we are stopping sound