dtmf

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: BSD-2-Clause Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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