audio: add Mixer doc

This commit is contained in:
faiface 2017-07-08 14:54:01 +02:00
parent 95b9f23076
commit f97894ad37
1 changed files with 6 additions and 0 deletions

View File

@ -1,17 +1,23 @@
package audio
// Mixer allows for dynamic mixing of arbitrary number of Streamers. Mixer automatically removes
// drained Streamers. Mixer's stream never drains, when empty, Mixer streams silence.
type Mixer struct {
streamers []Streamer
}
// Len returns the number of Streamers currently playing in the Mixer.
func (m *Mixer) Len() int {
return len(m.streamers)
}
// Play adds Streamers to the Mixer.
func (m *Mixer) Play(s ...Streamer) {
m.streamers = append(m.streamers, s...)
}
// Stream streams all Streamers currently in the Mixer mixed together. This method always returns
// len(samples), true. If there are no Streamers available, this methods streams silence.
func (m *Mixer) Stream(samples [][2]float64) (n int, ok bool) {
var tmp [512][2]float64