go-opengl-pixel/audio/compositors.go

18 lines
408 B
Go

package audio
// Seq takes zero or more Streamers and returns a Streamer which streams them one by one without pauses.
func Seq(s ...Streamer) Streamer {
i := 0
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
for i < len(s) && len(samples) > 0 {
sn, sok := s[i].Stream(samples)
samples = samples[sn:]
n, ok = n+sn, ok || sok
if !sok {
i++
}
}
return n, ok
})
}