Tone stream

From FreeSWITCH Wiki
Jump to: navigation, search

tone_stream://[L=x;][v=y;]%(<on-duration>, <off-duration>, <freq-1> [, freq-2] [, freq-3] [, freq-n] [;loops=x])

  • Durations are specified in milliseconds
  • Frequencies are specified in Hz

L=x; create x copies of the specified tone stream in memory before playing. Note that L=-1 is not valid, use loops=-1 to loop continuously. Specify L= at the beginning of the tone definition string.

;loops=x Loop x times, use ;loops=-1 for endless loop. This generates the tone, then repeats the generation process so it presumably consumers less cpu and memory than the L= parameter. Note that ;loops=x is postfix notation so it should appear at the end of the tone definition string.

v=y Volume of tones expressed as the equivalent in dB (deciBels) in a PCM waveform. 0 = maximum volume, negative integers represent softer volume (loudness). Do not enter positive values greater than zero! Note that non-linear formats such as G.711 and G.723 will offer slightly lower amplitudes as an artifact of their algorithms.

Examples

Adds a repeating (loop) 800Hz tone with a duration of 100ms and a 15 second intervening silence to a session:

 <action application="displace_session" data="tone_stream://%(100,15000,800);loops=-1" />

Plays a stutter-like tone 100 times:

 <action application="playback" data="tone_stream://L=100;%(100,100,350,440)" />

The frequencies specified are all additive. For example, %(4000,0,350,440) will simply play four seconds of 350 Hz with 440 Hz overlaid. To mimic frequency modulation, ring modulation theory can be used. Ring modulation works by taking the frequencies output by two oscillators, and both adding and subtracting them, producing "sum and difference" frequencies.

For example, the ringback tone of Romania is 450 Hz modulated by 25 Hz, for 1.85s on and 4.15s off. So frequency 1 should be 450 + 25 = 475 Hz, and frequency 2 should be 450 - 25 = 425 Hz:

 <action application="playback" data="tone_stream://%(1850,4150,475,425);loops=-1" />

Worldwide Frequencies and Cadences Listed by ITU-T

Various tones used in national networks (According to ITU-T Recommendation E.180) Updated 1st May 2010.

See Also

TGML complete listing of capabilities and syntax