Documentation
¶
Overview ¶
Package dtmf generates the dual-tone multi-frequency signals a telephone keypad produces, as 16-bit mono PCM. A transport that cannot signal a keypress natively sends the tone as audio instead, which is what carries a keypress down a call that only has an audio path.
Index ¶
Constants ¶
const ToneDuration = 500 * time.Millisecond
ToneDuration is how long one keypress occupies the audio stream: the tone itself and the pause that closes it. A keypress is a tone, not an instant, and a receiver that samples too short a burst does not register it.
Variables ¶
var ErrSampleRate = errors.New("dtmf: unusable sample rate")
ErrSampleRate is returned when the requested rate cannot carry a tone.
var ErrUnknownKey = errors.New("dtmf: not a keypad key")
ErrUnknownKey is returned for a key that is not on a telephone keypad and so has no tone pair.
Functions ¶
func Key ¶
func Key(button frames.KeypadEntry) bool
Key reports whether button is a key this package can sound.
func Tone ¶
func Tone(button frames.KeypadEntry, sampleRate int) ([]byte, error)
Tone renders one key as 16-bit little-endian mono PCM at sampleRate, lasting ToneDuration: toneOn of the two frequencies sounded together, then silence for the rest. A key that is not on a keypad is an error rather than silence, since silence would be indistinguishable from a tone nobody heard.
Types ¶
This section is empty.