tonescript v1.1.0
tonescript
What is tonescript:
this is tonescript.
Example:
var toneScript = require('tonescript');
toneScript('985@-16,1428@-16,1777@-16;20(.380/0/1,.380/0/2,.380/0/3,0/4/0)').play();
CLI:
This package comes with a bunch of pre-assembled tonescript "classic hits" that you might recognize if you're older than 30 and had a land line as a kid:
- busy
- call-forward
- comfort
- conference
- dial
- dial2
- dialo
- holding
- howler
- mwi
- prompt
- reorder
- ringback
- sit1
- sit4
- sit2
- sit3
If everything is working, the command will stay open playing the same tone until you give it the ol' sigint. On MacOS baudio seems flaky but it's historically worked well on Linux.
It also comes with a tonescript
CLI which will play a tone. For instance,
to play a howler:
$ tonescript '480@-10,620@0;10(.125/.125/1+2)'
playing tone 480@-10,620@0;10(.125/.125/1+2) at 0.2 decibels...
All commands optionally take a --db
option with a float value that defaults
to 0.2. You can adjust this to increase or decrease the volume.
API
var toneScript = require('tonescript');
toneScript(script, A0);
toneScript returns a baudio object. Use
the A0
parameter to adjust volume. Defaults to 0.2
. See
this article for more on what this
number actually means.
toneScript.toneGenerator(script, A0)
toneGenerator returns a function (t) {}, where t is in seconds, which returns A(t) with sin wave generators.
toneScript.parse(script)
This will return an object representing the tones specified in your tonescript. This is used by the toneGenerator and by the baudio player to generate tones.
tests
It's tough to automate testing this library, but you'll recognize the tones if they're playing correctly. Try them out and see if it's working.
license
MIT/X11.