|
VoiceResourcePlayTone Method (Int32, Int32, Int32) |
Plays a single tone at the desired frequency and amplitude for the requested duration.
Namespace:
VoiceElements.Client
Assembly:
VoiceElementsClient (in VoiceElementsClient.dll) Version: 8.6.1.1
Syntax public TerminationCode PlayTone(
int frequency,
int amplitude,
int duration
)
Public Function PlayTone (
frequency As Integer,
amplitude As Integer,
duration As Integer
) As TerminationCode
public:
TerminationCode PlayTone(
int frequency,
int amplitude,
int duration
)
member PlayTone :
frequency : int *
amplitude : int *
duration : int -> TerminationCode
Parameters
- frequency
- Type: SystemInt32
The frequency you would like the tone to have. - amplitude
- Type: SystemInt32
The amplitude or volume of the 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 Single Frequency Tones
Many tones may not seem so, but are actually two tones being played simultaneously. If you are looking for a tone not listed here, check the
Dual Frequency Play Tone Method. Below are some common 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.
-
Fax Tone: m_VoiceResource.PlayTone(2100, -17, 2000);
-
Operator Intercept 1: m_VoiceResource.PlayTone(950, -17, 2000);
aka Special Information Tone
-
Operator Intercept 2: m_VoiceResource.PlayTone(1400, -17, 2000);
aka Special Information Tone
-
Operator Intercept 3: m_VoiceResource.PlayTone(1800, -17, 2000);
aka Special Information Tone
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 fax tone on for 2 seconds, alternated with four seconds of silence using a
Thred.Sleep(4000);.
public void DialOutAndPlaySingleToneLoop()
{
TelephonyServer m_TelephonyServer = new TelephonyServer();
ChannelResource m_ChannelResource = m_TelephonyServer.GetChannel();
string phoneNumber = "2135551212";
m_ChannelResource.Dial(phoneNumber);
VoiceResource m_VoiceResource = m_ChannelResource.VoiceResource;
for (int i = 0; i < 10; i++)
{
m_VoiceResource.PlayTone(2100, -17, 2000);
Thread.Sleep(4000);
}
m_VoiceResource.Play(@"C:\Audio\Thanks_for_listening_to_our_tone.wav");
}
Public Sub DialOutAndPlaySingleToneLoop()
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
For i As Integer = 0 To 9
m_VoiceResource.PlayTone(2100, -17, 2000)
Thread.Sleep(4000)
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