Playing Tone Sequences
Playing a tone sequence is akin to playing an audio file (see Section 5.3) but sequence files are inherently simpler. Not only is no controller required but the sequence is decoded in the adaptation layer. Although the use case is similar to that of playing audio files, the calling pattern is similar to that of playing DTMF or tones.
There are several ways of playing a tone sequence:
• provide the tone sequence in a descriptor
• provide a filename that contains the tone sequence data
• use RFile::Open() to open a file that contains the tone sequence
• play a fixed sequence by index.
Internally there is not that much difference between them - the CMda-AudioToneUtility implementation reads the file contents into a descriptor and plays that-but that is internal and not really observable to the client. If you have a file, then generally we recommend using the RFile approach as it is easier to change your code to support files passed from other applications. However, in most situations the differences are minor.
Code would be similar to the DTMF example, but using different Prepare... calls:
void PrepareToPlayDesSequence(const TDesC8& aSequence); void PrepareToPlayFileSequence(const TDesC& aFileName); void PrepareToPlayFileSequence(RFile& aFile);
The two PrepareToPlayFileSequence() calls play a file when given either a filename or an RFile object. PrepareToPlayDes-
Sequence() effectively expects the contents of a file. Playing a fixed sequence is a bit different. They are built into the audio adaptation and are accessed by index. The following call plays a sequence:
void PrepareToPlayFixedSequence(TInt aSequenceNumber);
The following method tells you how many fixed sequences are provided on a given device:
TInt FixedSequenceCount();
The following method tells you the name of the associated sequence:
const TDesC& FixedSequenceName(TInt aSequenceNumber);
A key scenario is to read the names into a CDesCArray object, using a for loop, which can then be used as part of a selection box.
Apart from that, this API is similar in form to playing from a file. However, it is not always implemented. If it is not implemented, Fixed-SequenceCount() returns 0. If you do use these calls, take care to ensure that the behavior is valid if FixedSequenceCount() returns 0 - be careful of using choice lists with no content. Remember that the following call does not reliably play a sound:
PrepareToPlayFixedSequence(0);
If you do just want to make a sound, then playing simple tones is probably more reliable.
Post a comment