<Tone/>

The <Tone/> tag in Opentact's XML scripting is utilized to play a specified tone or sequence of tones during a call. This command is often used to generate specific signaling tones or messages for the caller or callee. The <Tone/> command supports various parameters to customize the tone playback.

Hints:

  • The tag attribute is a string used for call notification events if configured.

  • The loop parameter, with a default value of 1, creates multiple copies of the specified tone stream in memory before playing.

  • The volume parameter controls the loudness of the tones, expressed as the equivalent in dB (deciBels) in a PCM waveform. A value of 0 represents maximum volume, while negative integers indicate quieter volume.

  • The don and doff parameters set the on and off durations of the tone cadence.

  • The hz parameter is an array that specifies the frequencies of the tones to be played. Multiple frequencies can be provided, and the sequence can be repeated using the x notation.

  • The timeout parameter, with a default value of 30,000 milliseconds, sets the command execution timeout.

  • The leg parameter allows you to specify whether the tone should be played on the 'aleg', 'bleg', or 'both'.

Examples:

  1. 1 sec 480Hz tone:

    xmlCopy code<Tone don="1000" hz="480"/>
  2. Same tone, but louder:

    xmlCopy code<Tone don="1000" v="-70" hz="480"/>
  3. US ringing tone:

    xmlCopy code<Tone don="2000" hz="420,500,440,480"/>

These examples showcase the flexibility of the <Tone/> command, allowing for the creation of diverse tone sequences with customizable attributes.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Answer/>
    <!-- Play a tone -->
    <Tone />

    <!-- Dial a SIP user -->
    <Dial>
        <To>mary@dnl.sip.stage.opentact.org</To>
    </Dial>

    <!-- Play another tone -->
    <Tone />

    <!-- Speak a closing message -->
    <Say>Have a nice day</Say>

    <!-- End the call -->
    <Hangup/>
</Response>

In this example, the <Tone/> command is strategically placed within a call flow. The first tone is played immediately after answering the call, creating a distinctive auditory signal. Then, the call proceeds to dial a SIP user. Another tone is played after the dialing operation, adding further audio cues. Finally, a polite message is spoken using <Say/>, followed by hanging up the call. This example demonstrates how <Tone/> can be integrated seamlessly into the overall call handling process.

Last updated