Expand description
Telephony tone synthesis.
Call-progress tones are not recordings — they are specifications (ITU-T E.180 and the national supplements): a few sine frequencies in a fixed on/off cadence. Generating them beats shipping WAV files on every count: nothing to license, any sample rate we like instead of 8 kHz mu-law, an exact cadence, and a seamless loop.
A tone is written the way Asterisk’s indications.conf writes it, so any of
its 50 country zones can be pasted in verbatim:
425/1000,0/4000 Germany, ringback: 425 Hz for 1 s, then 4 s of silence
440+480/2000,0/4000 North America, ringback: two mixed frequenciesElements are separated by commas; each is freq[+freq…]/milliseconds, and a
frequency of 0 is silence. Asterisk’s * (modulation) and ! (play once)
are not supported — say so in the error rather than mis-playing them.
Structs§
- Chime
- A short motif of struck notes, plus the silence that follows it — so a looping alert carries its own cadence and needs no gap bolted on.
- Parse
Error - Why a tone spec could not be read. The message completes the sentence “the tone …”, so it reads as one line in a log.
- Partial
- A partial of a struck note: its frequency as a multiple of the fundamental, and its amplitude relative to it.
- Segment
- One stretch of a tone: which frequencies sound, and for how long.
An empty
freqsis silence — that is how a cadence’s gap is written. - Timbre
- How a struck note is coloured and how long it rings.
- Tone
- A complete tone: the segments of exactly one cadence period.
Constants§
- DE_BUSY
- Germany, busy (Besetztton) — the called party is on the phone.
Asterisk zone
[de],busy. - DE_
CONGESTION - Germany, congestion (Gassenbesetztton) — the network could not put the call
through. Same frequency as busy at twice the rate, which is exactly the
distinction between a SIP 486 and any other failure.
Asterisk zone
[de],congestion. - DE_
RINGBACK - Germany, ringback (Freiton). Shared with most of Europe and, per ITU-T,
much of the world. Asterisk zone
[de],ring. - MESSAGE
- New voicemail: two descending notes, played once. Deliberately smaller than the ring — it reports something, it does not ask for you.
- RING
- Incoming call: an ascending G–C–E triad, repeating every 2.5 s. Modern ringtones are a short motif in a cadence, not a continuous tone.
- SOFT
- Nearly a pure sine, with a touch of the octave — the quietest of the timbres we tried, and the one that stays bearable on the tenth repetition. Adding another is six lines: partials as multiples of the fundamental, plus a decay. A marimba is 1/4/10 and 600 ms, struck glass 1/2/2.4/3/4.5 and 1100 ms.
Functions§
- render
- Render
periodsrepetitions oftoneas mono S16 samples atsrate. - render_
chime - Render one period of
chimeas mono S16 samples atsrate.