DESCRIPTION
It is a complete interface for Voice Modems, like "US Robotics
Sportster 33.6 Voice" and similar. It makes easy to use your voice modem as a player or recorder or both, like
an answering machine or an automatic voice caller, detecting RING
and DTMF tones at the same time. The use of TMsgVoc is
simple, however some experience in modems and telephone lines is suggested. The operations
of TMsgVoc are ruled by going end exit different status. For a list of them see GetStatus.
Playing voice
TMsgVoc takes care of all the phases of dialing, connecting, playing, stopping playing
and disconnecting. All the phases of working of TMsgVoc can be displayed calling the
method GetStatus or GetStatusString
and the dialogue with the modem can be seen reading the string ModemDialog,
at any moment. The following table lists the sequence of possible operations.
Sequence | Method | String sent to the modem | Example of string | Event raised in case of success |
Initialization | GoInit | InitString | &F M1 L2 S40=2 #CLS=8 #VSM=128,8000 | OnInit |
Dialing and connecting in Voice Command Mode | GoDialConn | DialNum | 0024 621 4934 9945 | |
ConnString | H1 A | OnConn | ||
TX mode | GoTX | AT#VTX | OnTX | |
Playing | Play | all the bytes of 'filename' | OnPlayed (at the end of playing) | |
End of TX mode | GoEndTX | <DEL><ETX> | OnEndTX | |
Disconnetting | GoDisc | DiscString | H0 |
Recording voice
You can also use TMsgVoc to record, setting RecFile
with the name of the file where to store the recorded voice. Recording starts with the
method GoRX and stops with the method GoEndRX.
All the phases of working of TMsgVoc can be displayed calling the method GetStatus or GetStatusString, the
dialogue with the modem can be seen reading the string ModemDialog,
at any moment. The following table lists the sequence of possible operations.
Sequence | Method | String sent to the modem | Example of string | Event raised in case of success |
Initialization | GoInit | InitString | &F M1 L2 S40=2 #CLS=8 #VSM=128,8000 | OnInit |
Dialing and connecting in Voice Command Mode | GoDialConn | DialNum | 0024 621 4934 9945 | |
ConnString | H1 A | OnConn | ||
RX mode and recording to RecFile | GoRX | AT#VRX | OnRX | |
End of RX mode | GoEndRX | <DEL> | OnEndRX | |
Disconnetting | GoDisc | DiscString | H0 |
Detecting DTMF tones
During any phase of operations of TMsgVoc, excluding the status stDisc and
stInit, DTMF tones are received and recognized by TMsgVoc. In this case OnDTMF
is raised.
Detecting RING
During any phase of operations of TMsgVoc, included the status stDisc, RING
is detected and, in this case, OnRING is raised.
Setting the serial port
The serial port is handled directly by the component, so that only ComPortNumber and ComPortBaudRate
must be set.
Setting the modem
It is not very easy to get information about the right settings of modems in
general, regarding playing and recording voice. Be sure nothing of the kind can be found
in the operating or technical manual, and very little in the "at commands"
manual. Check also my Useful links
The default settings found in the component TMsgVoc are correct to perform operations
using a "US Robotics Sportster Voice 33600" with the protocol GSM 6.10 USR
(AT#VSM=128,8000). The following tabel lists the possible settings for US Robotics
Sportster Voice 33.6:
AT#VSM= | Compression method |
ComPortBaudRate to be set at |
128,8000 | GSM USR | br19200 |
129,8000 | G721 ADPCM USR | br38400 |
130,8000 | IMA ADPCM USR | br38400 |
ComPortBaudRate
The baud rate used to set the com port, to send/receive data to/from the modem.
TComPortBaudRate = ( br110, br300, br600, br1200, br2400, br4800,br9600, br14400,
br19200, br38400, br56000,br57600, br115200 );
property ComPortBaudRate: TComPortBaudRate;
It should be set at the right speed to be sure that the voice be digitalized at
the right speed during both recording and playing. Check your modem manual or, better, ask
the manufacturer of modem. For example, US Robotics Sportster Voice operates correctly
using protocol GSM (#VSM=128,8000) only if you set
ComPortBaudRate := br19200;
ConnString
The string to set the modem to connect in Voice mode.
property ConnString : string;
For example, for USR Sportster Voice: #CLS=8 #VSM=129,8000 #VLS=2 sets the modem
in voice (#CLS=8), it plays in G721 format (#VSM=129,8000), it sends voice to the
headphone connected to the modem (#VLS=2)
DialNum
It is the phone number to be dialed before playing the vocal message.
property DialNum : string;
Write here the phone number to be dialed, for example 4044931. It will be used in
the "at command" atd4044931; so some modifiers can be inserted, like p0,4044931
to wait for the external line of a telephone exchange, dialing with pulses, or similar.
DiscString
The string to stop Voice mode and to return On hook
property DiscString : string;
For all the modems I know, it will be: H0
InitString
The string of at command to initialize the modem.
property InitString : string;
Set InitString with the AT commands to set your modem before beginning dialing
and the other operations. For example, for USR Sportster Voice:
&F1 M1 L3 S40=2 #CLS=8 #VSM=129,8000 #VLS=2
resets the modem parameters (&F), turn on the loudspeaker (M1), pop up the volume
(L3), disables count of dialling (S40=2), sets the modem in voice (#CLS=8), it plays in
G721 format (#VSM=129,8000), it sends voice to the headphone connected to the modem
(#VLS=2).
See alse ConnString and GoConn
LastingTime
It is the maximum time of activity, in milliseconds, for the complete cycle off
hook-dialing-playing-on hook
property LastingTime : Integer;
Set this property to play a long recording or to be sure that, after LastingTime
msec the connection will be interrupted. Even if NumRep is set to play a very long
recording, after LastingTime msec, playing will be interrupted all the same.
PollingTime
Internal polling time of TMsgVoc
property PollingTime:Integer;
This time is set to 200 msecs, by default. Don't modify it; try other values only
if you are modifying TMsgVoc itself. Try shorter values 200-100 msec if your modem is
playing the voice with unwanted pauses.
RecFile
The name of the file to be overwritten, or created if it doesn't exist, to store the
recorded voice.
property RecFile : string;
The format of the file will depend on the format set in the modem with the
command #VSM=.....
The extension of RecFile is not automatic.
See also RecConn
Active
Read Only. If TMsgVoc is working, it will be True, otherwise it will be False
property Active : Boolean;
It can be used to see if TMsgVoc can receive commands. If Active is True,
many properties can't be modified.
GoDialConn
TMsgVoc will dial and force the modem to go into the 'Command Voice mode'
procedure GoDialConn;
TMsgVoc will send DialString to the modem and, in case of success, it will send
ConnString as well.
GoConn
TMsgVoc will force the modem to go into the 'Command Voice mode', without
dialing
procedure GoDialConn;
TMsgVoc will send ConnString to the modem and, in case of success, it will enter
in the status stConn.
GoTX
TMsgVoc will force the modem to go into the 'TX mode', from where voice can
be played.
procedure GoTX;
TMsgVoc will send AT#VTX to the modem and, in case of success, it will enter in
the status stTX.
GoEndTX
TMsgVoc will force the modem to exit the 'TX mode'
procedure GoEndTX;
TMsgVoc will send <DLE> < ETX> to the modem and it will go back
to the stConn status.
GoRX
TMsgVoc will force the modem to go into the 'RX mode' and it will begin to
record into the RecFile.
procedure GoRX;
TMsgVoc will send AT#VRX to the modem, it will enter in the status stRX and it
will begin to record into the RecFile. If RecFile doesn't exist, it will be created,
otherwise it will be overwritten.
GoEndRX
TMsgVoc will force the modem to exit the 'RX mode'
procedure GoEndRX;
TMsgVoc will send <DLE> to the modem and it will go back to the
stConn status.
GoDisc
It stops playing or recording and sets the modem on hook.
procedure GoDisc;
It sends VocDisc to the modem and, after that, it sends ATH0,
setting the modem off hook. It can be given whenever it could be useful.
See Also: GetStatus
Play
It plays the file, whose name is filename, NumRep times.
procedure Play(filename : string; NumRep : Integer) ;
if TMsgVoc is in TX status, it will play filename, NumRep times. Be sure to
set filename to a proper file because no control or automatic setting will take place
inside TMsgVoc. For example, if you set it using the name of a text file, it will be sent
to the modem all the same and an odd noise will come out from the modem. Besides, take
care the file is in the correct format, like GSM, ADPCM and so on. To see the formats that
your modem can play and record give the command AT#VSM=? Play can be called asynchronously
or driven by the event OnConn When playing is finished, the event OnPlayed will be raised.
See also OnConn
GetStatus
It gives the status of playing or recording.
function GetStatus : TMsgVocStatus;
During any activity of TMsgVoc, it returns a string corresponding to the
following status.
GetStatusString
It gives the status of playing or recording.
function GetStatusString : string;
During any activity of TMsgVoc, it returns a string corresponding to the
following status.
Status | Description | Modem status | Notes |
stGoDisc |
DiscString, usually ATH0, is sent to the modem | ||
stWaitDisc |
waiting for OK | ||
stDisc |
On hook | ||
stGoInit |
InitString is sent to the modem | On hook | |
stWaitInit | waiting for OK from the modem | On hook | |
stInit | OK arrived | On hook - initialized | GoConn, GoDial or GoDisc can be given |
stGoDial | DialString is sent to the modem | On hook - dialing | |
stWaitDial | waiting for OK from the modem | On hook - dialing | |
stDial | OK arrived | Off hook | it goes automatically to stGoConn |
stGoConn | ConnString is sent to the modem | On hook | |
stWaitConn | waiting for VCON from the modem | On hook | |
stConn | VCON arrived | On hook - Command Voice mode | GoDisc, GoTX or GoRX can be given |
stGoTX | AT#VTX is sent to the modem | On hook - Command Voice mode | |
stWaitTX | waiting for 'CONNECT' | On hook - Command Voice mode | |
stTX | 'CONNECT' arrived | On hook - TX mode | GoEndTX can be given |
stGoEndTX | <DLE> <ETX> is sent to the modem | ||
stWaitEndTX | waiting for 'VCON' | ||
stEndTX | 'VCON' arrived | it goes automatically to stGoConn | |
stGoRX | AT#VRX is sent to the modem | On hook - Command Voice mode | |
stWaitRX | waiting for 'CONNECT' | On hook - Command Voice mode | |
stRX | 'CONNECT' arrived | On hook - RX mode | GoEndRX can be given |
stGoEndRX | <DLE> is sent to the modem | ||
stWaitEndRX |
waiting for 'VCON' | ||
stEndRX |
'VCON' arrived | On hook - Command Voice mode | it goes automatically to stGoConn |
ModemDialog
It contains the strings received from the modem.
property ModemDialog : string;
The last 255 characters received from the modem, and even those sent to the
modem, if modem echoes, are contained here. It can be used for troubleshooting or
for the sake of curiosity.
OnConn
It is raised when the modem goes into 'VoiceCommand Mode', i.e. a
listener answered, so that TMsgVoc can play, record or simply receive DTMF keys.
When a "voice modem" originates a call, it sends a VCON when it detects no more
"ring back", supposing the remote listener has answered going off hook. See also
the commands AT#VRA and AT#VRN which should be placed in the ConnString string. If the
determination of the end of ring back is doubtful, it is better to place an A at the end
of the string ConnString, so that the event OnConn is originated immediately. This event
can be used to start playing of a file with the method Play.
OnDTMF
It is raised when a DTMF is received, i.e. when the remote listener presses a DTMF
key. The decoded DTMF keys are
'0'..'9','*','#','A'..'D'
besides the following special codes are used
'b' for busy,'c' for ,'d' for ,'q' for ,'s' for
OnEndRX
It is raised whenever the modem exits the RX mode, see also GoEndRX and GetStatus.
OnEndTX
It is raised whenever the modem exits theTX mode, see also GoEndTX and GetStatus.
OnInit
It is raised whenever the modem has been initialized correctly with InitString.
OnPlayed
OnPlayed is raised after a file, set by the method Play, is played NumRep times
and completely. It can bu used to call GoEndTX or for different strategies of playing or
recording.
OnRING
It is raised every time a RING is received.
OnRX
It is raised whenever the modem enters the RX mode, see also GoRX and GetStatus.
OnTX
It is raised whenever the modem enters the TX mode, see also GoTX and GetStatus.
This page was written by guido@sienanet.it