(Page 1 of 1 in this chapter)


Chapter 3

Playing and Recording


3.1 Introduction
3.2 Playing
3.2.1 Playing Functions
3.2.2 Playing Completion Reasons
3.2.3 Speed and Gain Adjustment
3.2.4 Parameters
3.3 Recording
3.3.1 Recording Functions
3.3.2 Recording Completion Reasons
3.3.3 Resizing Messages
3.3.4 Parameters
3.4 Playing and Recording States
3.5 Stopping
3.6 DTMF Interaction

3.1 Introduction

This chapter explains how to use the Voice Message service to perform playing and recording.

3.2 Playing

There are two types of playing functions.

There are no buffer-oriented play functions in the Voice Message service. Use the ADI service function adiPlayAsync or adiStartPlaying if you need direct access to buffers. Refer to the ADI Service Developer's Manual and to the ADI Service Function Reference Manual for more information on ADI functions.

The vceplay demonstration program demonstrates playing messages from one or more voice files. Refer to Section 9.2.3 for more information.

3.2.1 Playing Functions

The following table lists when to use the play functions available in the CT Access Voice Message service:

If you want to...

Then use...

Start playing from the current position in the current message

vcePlay

Start playing from the beginning of the first message in a list of messages

vcePlayList

Play one message from a specified voice object

vcePlayMessage

Change the current play speed to a specified rate

vceSetPlaySpeed

Change the volume (loudness) of message playback by adjusting the amplification, or gain, applied to the message being played

vceSetPlayGain

3.2.2 Playing Completion Reasons

The following table lists the Voice Message service reason codes returned when play terminates. The reason is stated in the value field of the VCEEVN_PLAY_DONE_EVENT.

Note: If play fails, the value field will contain an error code.
If...

The DONE event contains...

The end of the current message or list is reached

CTA_REASON_FINISHED

The time limit in vcePlay is reached

CTA_REASON_TIMEOUT

Play is stopped by calling vceStop

CTA_REASON_STOPPED

A touch tone digit is received and the corresponding bit in the DTMF abort parameter is set

CTA_REASON_DIGIT

The call is ended

CTA_REASON_RELEASED

Play is stopped because of a speech recognition event

CTA_REASON_RECOGNITION

You play an object that has an encoding that is not supported by the attached device service

CTAERR_FUNCTION_NOT_AVAIL

3.2.3 Speed and Gain Adjustment

You can set the volume (vceSetPlayGain) and speed (vceSetPlaySpeed) of play at any time. The new volume (gain or amplification) and the new speed are stored in the current CTA context. If play is currently active, the change takes effect immediately. If you want a gain or speed change to carry over to the next play function, set the play gain or speed parameter on the next play to VCE_CURRENT_VALUE.

The playing speed may also be adjusted for some encodings. Speed control is available for the NMS ADPCM encodings (VCE_ENCODE_NMS_xx) and the OKI ADPCM encodings (VCE_ENCODE_OKI_xx).

To enable speed up, increase the maxspeed play parameter from its default value of 100. When play is started with a higher value of maxspeed, the necessary DSP resources are allocated to support increased speed. You can start play with a fast speed (up to maxspeed) by changing the value of the speed parameter.

To use speed up with NMS ADPCM on AG boards, replace voice.dsp in the ag.cfg file with voxp.dsp and voxr.dsp.

Note: Starting play with maxspeed greater than 100 requires additional DSP resources beyond that required for playing at normal speed. To determine whether your AG board(s) and configuration can support speed up, refer to the AG Runtime Configuration and Developer's Manual.

Use vceGetContextInfo to get the current gain and speed values.

3.2.4 Parameters

The play functions take an optional pointer to a parameter structure. If you pass NULL, the parameters take default values. Refer to Appendix C for more information about the play parameters. Refer to the CT Access Developer's Reference Manual for more information on parameters.

Field Name

Default Value

Description

DTMFabort

0xffff

Abort on DTMF (bit mask).

gain

0

Playing gain in decibels, or VCE_CURRENT_VALUE to use the most recent gain setting.
The valid range for AG boards is -54 to 24.

speed

100

Initial speed in percent, or VCE_CURRENT_VALUE to use the most recent speed setting. The valid range for AG boards is 50 - maxspeed.

maxspeed

100

Maximum play speed in percent. The valid range for AG boards is 100 - 200.

3.3 Recording

There are two types of recording functions:

There are no buffer-oriented record functions. Use the ADI functions adiRecordAsync or adiStartRecording if you need direct access to buffers. Refer to the ADI Service Developer's Manual for more information on playing and recording with the ADI service. Refer to the ADI Service Function Reference Manual for more information on the ADI service functions.

The vcerec demonstration program demonstrates copying messages from one voice file to another. Refer to Section 9.2.4 for more information.

3.3.1 Recording Functions

Recording optionally starts with a beep tone. The recording functions have a time limit. Silence detected during recording can optionally abort the recording.

The following table lists when to use the record functions available in the CT Access Voice Message service:

If you want to...

Then use...

Start recording at the current position in the current message

vceRecord

Record a message into a specified voice object

vceRecordMessage

3.3.2 Recording Completion Reasons

The following table lists the Voice Message service reason codes returned when record terminates. The reason is stated in the value field of the VCEEVN_RECORD_DONE_EVENT.

Note: If record fails, the value field will contain an error code.
If...

The DONE event contains...

The time limit in vceRecord is reached

CTA_REASON_TIMEOUT

No more space is available in the voice object, or recording in overwrite mode reached the end of the existing message

CTA_REASON_FINISHED

Silence is detected at the beginning of recording

CTA_REASON_NO_VOICE

Silence occurs after some energy is recorded

CTA_REASON_VOICE_END

Record is stopped at any time by calling vceStop

CTA_REASON_STOPPED

A touch tone digit is received and the corresponding bit in the DTMF abort parameter is set

CTA_REASON_DIGIT

The call is ended

CTA_REASON_RELEASED

Record is stopped because of a speech recognition event

CTA_REASON_RECOGNITION

You record to an object with an encoding that is not supported by the attached device service

CTAERR_FUNCTION_NOT_AVAIL

3.3.3 Resizing Messages

When a message is replaced by vceRecordMessage, the new message might be larger or smaller than the previous one. The ability to resize a message depends on the object and the position of the message in the object. A message in a VOX file or a message that is located at the end of a flat (unformatted) file can grow without limit (until the disk is full). A file can physically shrink if the message at the end of the file is replaced with a smaller one (the shrinkage occurs when the file is closed). A message in a memory block is limited to the size of the memory specified with vceOpenMemory.

There is usually only one message in a flat file or a memory block. If there is more than one message in a flat file or memory block and a message in the middle is replaced, the new message cannot be larger than the existing message. vceRecordMessage ends with CTA_REASON_FINISHED when the limit is reached.

3.3.4 Parameters

The record functions take an optional pointer to a parameter structure. If you pass NULL, the parameters take default values. Refer to Appendix C for more information about the record parameters. Refer to the CT Access Developer's Reference Manual for more information on parameters in CT Access.

Automatic Gain Control (AGC) is an algorithm applied to incoming speech (recording) before compression and storage so that the amplitude of the stored speech is kept at a target level.

The following parameters control the beep tone, silence detection, record gain (including optional Automatic Gain Control), and DTMF abort.

Field Name

Default Value

Description

DTMFabort

0xffff

Abort on DTMF (bitmask).

gain

0 dB

The gain in decibels applied to the signal before it is encoded. If Automatic Gain Control is enabled, this is the initial gain when recording starts. Valid range for AG boards is -54 to 24.

novoicetime

5000 ms

The maximum length of silence at the beginning of a recording before recording will be stopped with a reason of CTA_REASON_NO_VOICE. Use zero (0) to disable this timer. Valid range for AG boards is 0 - 65535.

silencetime

3000 ms

The maximum length of silence after audio energy has been detected before record will be stopped with a reason of CTA_REASON_VOICE_END. Use zero (0) to disable this timer. Valid range for AG boards is 0 - 65535.

silenceampl

-45 dBm

The maximum signal level, in dBm, that is considered to be silence. Valid range for AG boards is -51 to -15.

beepfreq

1000 Hz

The frequency of the record beep tone. Use zero (0) to disable the beep. Valid range for AG boards is 200 - 3600.

beepampl

-20 dBm

The amplitude of the beep tone. Valid range for AG boards is
-54 to 3.

beeptime

200 ms

The duration of the beep. 0 disables the beep. Valid range for AG boards is 0 - 65535.

AGCenable

0

Flag to enable Automatic Gain Control.

Note: When using AG boards, the parameters presented in the previous table override the corresponding fields in the ADI.RECORD category. ADI.RECORD contains additional fields which you can use to control Automatic Gain Control (AGC) characteristics.

Figures 4, 5, and 6 illustrate the three time windows that terminate the record function:

Figure 4. Record Termination - No Voice




Figure 5. Record Termination - Voice End




Figure 6. Record Termination - Timeout

3.4 Playing and Recording States

This section illustrates and explains the playing and recording states.

Figure 7. Playing and Recording States


Idle: The play and record functions are not active.

Playing: When the application initiates playing by invoking a play function (vcePlay, vcePlayList, or vcePlayMessage), the Voice Message service is in the playing state.

Recording: When the application initiates recording by invoking a record function (vceRecord or vceRecordMessage), the Voice Message service is in the recording state.

Play Stopping: The application initiates stopping the play by invoking vceStop. The Voice Message service generates a VCEEVN_PLAY_DONE event and returns to the idle state.

Record Stopping: The application initiates stopping the record by invoking vceStop. The Voice Message service generates a VCEEVN_RECORD_DONE event and returns to the idle state.

The playing or recording state remains active until either:

3.5 Stopping

Call vceStop to stop playing or recording. Stopping play or record results in a DONE event. The value field of the DONE event will contain CTA_REASON_STOPPED.

Note: CTA_REASON_STOPPED is also returned if playing or recording is stopped when the voice object being played or recorded is closed with vceClose. If you are playing a list, playing is stopped if an object containing any message in the list is closed.

3.6 DTMF Interaction

When initiating play or record, the application can program the function to terminate play or record when a DTMF key is depressed by the remote party. By default, play or record terminates when any DTMF key is entered. The play parameter structure and the record parameter structure provide a selective DTMF abort mask specifying which DTMF keys terminate the function.

The DTMF abort mask is a 16-bit entity where each bit corresponds to a specific key on the telephone keypad. Setting a bit in the mask causes the voice function to terminate if that particular key is entered. The DTMF abort mask corresponds to the DTMF telephone keys as shown:

Most Significant Bit

Least Significant Bit

Bit Position

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0

DTMF Key

D

C

B

A

#

*

9

8

7

6

5

4

3

2

1

0

For example, if the abort mask is set to 0x03FF, the playing/recording functions will terminate if any digit from 0 through 9 is entered by the remote party. The vcedef.h include file contains #defines (VCE_DTMF_xxx) for each digit and for certain digit groups.



(Page 1 of 1 in this chapter)


tech_support@nmss.com
Copyright © 1999, Natural MicroSystems, Inc. All rights reserved.