vox

package
v0.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Vox)

Option is the type for a function option

func Enabled

func Enabled(enabled bool) Option

Enabled is a functional option to initialize the Vox object with an enabled or disabled vox.

func HoldTime

func HoldTime(t time.Duration) Option

HoldTime is a function option to set the hold time of the vox.

func StateChanged

func StateChanged(f func(bool)) Option

StateChanged is a functional option to provide a callback which be executed whenever the Vox is triggered or cut off.

func Threshold

func Threshold(t float32) Option

Threshold is a functional option to set the initial audio threshold level when the vox kick's in. The range must be between 0 ... 1.

type Vox

type Vox struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Vox is an Audio Node which detects if the audio level raises above or falls below a defined threshold level.

func New

func New(opts ...Option) *Vox

New is the constructor method for a Vox Object. Vox implements an audio.Node and emits a StateChanged callback when the RMS (root mean square) has fallen above or below the set threshold. By default the threshold is set to 0.1 and the hold time to 500ms.

func (*Vox) Enable

func (v *Vox) Enable(state bool)

Enable or disable the vox. If the vox is disabled, the audio data will be passed on to the next audio node in the chain.

func (*Vox) Enabled

func (v *Vox) Enabled() bool

Enabled returns a boolean value indicating if the vox is enabled. If not, the audio data is directly passed on to the next audio node in the chain.

func (*Vox) Holdtime

func (v *Vox) Holdtime() time.Duration

Holdtime returns the current vox holdtime

func (*Vox) SetCb

func (v *Vox) SetCb(cb audio.OnDataCb)

SetCb sets the callback which will be called when the data has been processed and is ready to be sent to the next audio.Node or audio.Sink.

func (*Vox) SetHoldTime

func (v *Vox) SetHoldTime(t time.Duration)

SetHoldTime sets the vox hold time. The hold time is the duration which will be waited until a statechange event is emitted.

func (*Vox) SetThreshold

func (v *Vox) SetThreshold(value float32)

SetThreshold sets the value for the vox threshold. Only values between 0...1 are allowed. Values below or above will be clipped to the minimum or maximum.

func (*Vox) Threshold

func (v *Vox) Threshold() float32

Threshold returns the vox threshold value.

func (*Vox) Write

func (v *Vox) Write(msg audio.Msg) error

Write is the entry point into this audio Node. Writing an audio.Msg will start the processing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL