|
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
)
Public Function PlayTone (
frequency1 As Integer,
amplitude1 As Integer,
frequency2 As Integer,
amplitude2 As Integer,
duration As Integer
) As TerminationCode
public:
TerminationCode PlayTone(
int frequency1,
int amplitude1,
int frequency2,
int amplitude2,
int duration
)
member PlayTone :
frequency1 : int *
amplitude1 : int *
frequency2 : int *
amplitude2 : int *
duration : int -> TerminationCode
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()
{
TelephonyServer m_TelephonyServer = new TelephonyServer();
ChannelResource m_ChannelResource = m_TelephonyServer.GetChannel();
string phoneNumber = "2135551212";
m_ChannelResource.Dial(phoneNumber);
VoiceResource m_VoiceResource = m_ChannelResource.VoiceResource;
m_VoiceResource.PlayTone(350, -17, 440, -17, 10000);
for (int i = 0; i < 100; i++)
{
m_VoiceResource.PlayTone(480, -17, 620, -17, 500);
Thread.Sleep(500);
}
m_VoiceResource.Play(@"C:\Audio\Thanks_for_listening_to_our_tone.wav");
}
Public Sub DialOutAndPlayDualToneLoop()
Dim m_TelephonyServer As New TelephonyServer()
Dim m_ChannelResource As ChannelResource = m_TelephonyServer.GetChannel()
Dim phoneNumber As String = "2135551212"
m_ChannelResource.Dial(phoneNumber)
Dim m_VoiceResource As VoiceResource = m_ChannelResource.VoiceResource
m_VoiceResource.PlayTone(350, -17, 440, -17, 10000)
For i As Integer = 0 To 99
m_VoiceResource.PlayTone(480, -17, 620, -17, 500)
Thread.Sleep(500)
Next
m_VoiceResource.Play("C:\Audio\Thanks_for_listening_to_our_tone.wav")
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also