View Full Version : Audio Playback

11-20-08, 11:28 AM

I'm playing back audio using the MonteCarlo API. I play the first one and then I play the second one. However when I play the second wav file, the audio of the first wav is played again, followed by the second wav file.

I am submitting each wav files as a single buffer submitted using PK_AUDIO_OutputAddBuffer with the the dwFlag set to PK_AUDIO_LAST_BUFFER as there are no buffers to follow.

Is it possible to flush the audio buffer before I play the second one or am i doing something wrong?

Many thanks


11-24-08, 05:04 AM
With MC low level programming, it is the responsibility of the user application to create and manage the audio buffers.

I would therefore suspect that something in the application is appending to, rather than clearing the first audio file when you come to add the second one.

Do you have some sample code you can post ?

Presumably you are doing a PK_AUDIO_OutputAddBuffer() and then a PK_AUDIO_OutputStart () ? Are you then waiting till you see a
PK_EVENT_AUDIO_OUTPUT_IDLE event, before repeating the process with the 2nd file ? If so, then the Pika API will have finished with the original audio buffer and you should clear those buffer pointers (or overwrite them) with the details of the 2nd audio file.

If you actually wanted to play 2 file in succession, you should add two buffers using the PK_AUDIO_OutputAddBuffer() function. You would then expect to see a PK_EVENT_AUDIO_RETURN_ADD_BUFFER() event when buffer completes playing and a PK_EVENT_AUDIO_OUTPUT_IDLE after the last file.

11-24-08, 07:30 AM
Hi Martin,

It appears the PIKA code is correct and it is actually sending the same file twice to be played.

Thanks for your reply.