Click or drag to resize

VoiceResourcePlayTone Method (Int32, Int32, Int32, Int32, Int32)

Plays two mixed tones at the two specified frequencies and amplitudes for the requested duration.

Namespace:  VoiceElements.Client
Assembly:  VoiceElementsClient (in VoiceElementsClient.dll) Version: 8.6.1.1
Syntax
public TerminationCode PlayTone(
	int frequency1,
	int amplitude1,
	int frequency2,
	int amplitude2,
	int duration
)

Parameters

frequency1
Type: SystemInt32
The frequency you would like the first tone to be mixed tone to have.
amplitude1
Type: SystemInt32
The amplitude or volume of the first tone.
frequency2
Type: SystemInt32
The frequency you would like the second tone to be mixed tone to have.
amplitude2
Type: SystemInt32
The amplitude or volume of the second tone.
duration
Type: SystemInt32
The duration in milliseconds you would like the tone to play.

Return Value

Type: TerminationCode
A Termination Code indicating how the play ended. Typically, you will use this to determine what to do next.
Remarks
Valid Ranges for Parameters

When playing tones, you control Frequency, Amplitude(volume), and duration of the tone. Below are the valid ranges and suggestions for each.

  • Frequency should range from 100 to 3000. The higher the number, the higher the "pitch" of the tone.
  • Amplitude can be from -1 to -20, but we strongly suggest for telephony applications to always use -17.
  • Duration is up to you and your tone needs, the value is in milliseconds.

Commmon Dual Frequency Tones

If you are looking for a tone not listed here (especially Special Information Tones), check the Single Frequency Play Tone Method. Below are some common dual frequency tones you may want to use in your code. Note that many of these tones are played repeatedly with differing amounts of silence in between. You will need to loop and for example do a Thread.Sleep(4000) for four seconds of silence. Se the code sample below for more detail.

  • Dial Tone: m_VoiceResource.PlayTone(350, -17, 440, -17, 30000); - Note the thrity second duration on this sample.
  • Busy Signalm_VoiceResource.PlayTone(480, -17, 620, -17, 500); - Note that 500 milliseoncds of silence is used in a loop.
  • Ring Back Tone: m_VoiceResource.PlayTone(440, -17, 480, -17, 2000); - Note that 4000 milliseoncds or 4 seconds of silence is used in a loop.

Examples
The following sample code sets up a Channel Resource, Dials a Call, retrieves a Voice Resource, and then goes into a loop where is plays a dial tone on for 10 seconds. After that, it plays a Busy Signal consisting of 500 millisecond tone with 500 milliseconds of silence using a Thred.Sleep(500);.
public void DialOutAndPlayDualToneLoop()
{
    // To get a channel, you must first get a link to a Telephony Server.  You may need to pass a username password here.
    TelephonyServer m_TelephonyServer = new TelephonyServer();

    // Get your channel resource from the server
    ChannelResource m_ChannelResource = m_TelephonyServer.GetChannel();

    // Example 1: Dial an oubound call
    string phoneNumber = "2135551212";
    m_ChannelResource.Dial(phoneNumber);

    // Get the voice resource and store in a variable for local use
    VoiceResource m_VoiceResource = m_ChannelResource.VoiceResource;

    // Now that the call has dialed, begin playing a dial tone for 10 seconds
    m_VoiceResource.PlayTone(350, -17, 440, -17, 10000);

    // Now that the dial tone has ended, begin playing busy signal in a loop with silence, loop 100 times
    for (int i = 0; i < 100; i++)
          {
        // Inside the loop, play 1/2 second of tone
              m_VoiceResource.PlayTone(480, -17, 620, -17, 500);
        Thread.Sleep(500); // 1/2 second of silence
          }

    // Play a file to thank the caller
    m_VoiceResource.Play(@"C:\Audio\Thanks_for_listening_to_our_tone.wav");

    // Take your code from here ... 
}
See Also