dtmf

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: BSD-2-Clause Imports: 6 Imported by: 0

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

View Source
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

View Source
var ErrSampleRate = errors.New("dtmf: unusable sample rate")

ErrSampleRate is returned when the requested rate cannot carry a tone.

View Source
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.

Jump to

Keyboard shortcuts

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