v0.1.0 initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package audio
|
||||
|
||||
// Muter gates playback of a wrapped Engine. The mute state is a host concern:
|
||||
// the engine state machine is unaware and both backends stay untouched
|
||||
type Muter struct {
|
||||
Engine
|
||||
muted bool
|
||||
}
|
||||
|
||||
func NewMuter(e Engine) *Muter { return &Muter{Engine: e} }
|
||||
|
||||
// Play forwards to the wrapped Engine unless gated. In-flight pw-play
|
||||
// processes are not killed; effects are under 300ms
|
||||
func (m *Muter) Play(fx Effect) {
|
||||
if !m.muted {
|
||||
m.Engine.Play(fx)
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle flips the gate and reports the new muted state
|
||||
func (m *Muter) Toggle() bool {
|
||||
m.muted = !m.muted
|
||||
return m.muted
|
||||
}
|
||||
|
||||
// Muted reports whether playback is gated
|
||||
func (m *Muter) Muted() bool { return m.muted }
|
||||
Reference in New Issue
Block a user