audio: add Mixer doc
This commit is contained in:
parent
95b9f23076
commit
f97894ad37
|
@ -1,17 +1,23 @@
|
||||||
package audio
|
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 {
|
type Mixer struct {
|
||||||
streamers []Streamer
|
streamers []Streamer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Len returns the number of Streamers currently playing in the Mixer.
|
||||||
func (m *Mixer) Len() int {
|
func (m *Mixer) Len() int {
|
||||||
return len(m.streamers)
|
return len(m.streamers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Play adds Streamers to the Mixer.
|
||||||
func (m *Mixer) Play(s ...Streamer) {
|
func (m *Mixer) Play(s ...Streamer) {
|
||||||
m.streamers = append(m.streamers, s...)
|
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) {
|
func (m *Mixer) Stream(samples [][2]float64) (n int, ok bool) {
|
||||||
var tmp [512][2]float64
|
var tmp [512][2]float64
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue