npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

touchtone

v1.0.2

Published

generate DTMF tones like a touchtone phone

Downloads

35

Readme

touchtone

generate DTMF tones like a touchtone phone

example

server example with baudio

Using baudio, we can make a tone script that runs on the server.

var tone = require('touchtone')();
tone.dial('18005551212');

var baudio = require('baudio');
baudio(tone.play()).play();

Make sure you have sox installed to use baudio.

browser example with webaudio

We can play tones in the browser using webaudio:

var tone = require('touchtone')();
var baudio = require('webaudio');

var form = document.querySelector('form');
form.addEventListener('submit', function (ev) {
    ev.preventDefault();
    var number = form.elements.number.value;
    tone.dial(number);
});

baudio(tone.play()).play();

usage

There is also a touchtone command that ships with this package.

USAGE

  touchtone {OPTIONS} NUMBER

INFO

  Play the DTMF tones for NUMBER on the system audio device.

OPTIONS

  -d --duration  Time in seconds to play each tone.

  -p --pause     Time in seconds to pause between tones.

  -v --volume    Volume: higher than 1: louder, lower than 1: softer.

  -h --help      Show this message.

EXAMPLE
  
  touchtone 18005551212
  touchtone '*69'

methods

var touchtone = require('touchtone')

var tone = touchtone(opts)

Create a new tone instance with opts:

  • opts.duration - time in seconds to play each tone
  • opts.pause - time in seconds between each tone
  • opts.volume - higher than 1: louder, lower than 1: quieter

tone.press(key)

Generate a single tone for a string character key.

tone.dial(number)

Generate a sequence of numbers from a string number.

tone.play()

Return a function (t) {} that itself returns an amplitude between -1 and 1, inclusive. This function can be fed into baudio or webaudio to generate sounds.

events

tone.on('ready', function () {})

When the queued-up tones are finished playing, this event fires.

DTMF keys

All 16 DTMF keys are supported:

 HZ  1209 1336 1477 1633
697    1    2    3    A
770    4    5    6    B
852    7    8    9    C
941    *    0    #    D

Refer to each key by its symbol name as a string.

install

First install sox unless you only want to use this module in a browser.

If you want the command-line client, do:

npm install -g touchtone

If you want the library, do:

npm install touchtone

license

MIT