Solved

Playing multiple wav files sequentially while waiting for user input

Posted on 1998-11-13
7
196 Views
Last Modified: 2013-11-20
I'm coding a simulation program. I couldn't find an efficient way of playing multiple wav files sequentially  pre specified times meanwhile if a user presses a specified key; stop playing.
I tried to use MCIWnd, but it is costly for such a task, also I thought using ::PlaySound() asynchronously but i couldn't find a way of getting end of play message.
I don't want to get deep into Waveform Audio API internals.
I thought that i can merge these files and make them one wave file. Play it asynchronously. But i couldn't find how to merge wave files.  
0
Comment
Question by:ryildirim
7 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324657
>> MCIWnd, but it is costly for such a task
Do you mean costly as in sucks up a lot of processor power?

>> ::PlaySound() asynchronously but i couldn't find a way of
>> getting end of play message.

You mean some kind of notification for when the file is done playing?  Unfortunately, with PlaySound, I don't believe there is such a feature, so it will almost certainly not work.

It seems like you could do the last idea with something as simple as "Sound Recorder" but I am not sure.
0
 

Author Comment

by:ryildirim
ID: 1324658
No I don't mean processing power, i mean that this is only a simple task and dealing with mciwnd in my application may bring too much overhead.

I mean a notification. In WaveForm api there is such a notification like PLAY_DONE or something like. But i find using Wave Form API too low level for such a task.

Merging files with sound recorder would be ok if i had specified them at design time. But these files will be merged at run-time.
0
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1324659
you will be not able to do that only with MCI API.
either you need to use DirectX.Direct Sound Mixer will implement multiWave files mixture or you need to use 3-part developement library .

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:ryildirim
ID: 1324660
I do not mean mixing several Wave files. I mean to play them sequencially one after another. And in the meantime wait for a user input.
0
 
LVL 2

Accepted Solution

by:
wyy_cq earned 200 total points
ID: 1324661
use MCI Command.
after you open a MCI device

you can send MIC_PLAY command with MCI_NOTIFY flag .
in this case you need specify a HWND ,
when play is over the window will be notified.
after your window receive the notify it can play the next file.

when you call the function ,the file will be played and the function will return at once.

code like under lines:

suppose you have opened the device and the wave file.

MCI_PLAY_PARMS mciPlayPara;
mciPlayPara.dwCallback=(DWORD)hWndNotify;
mciSendCommand(wDeviceID,MCI_PLAY,MCI_NOTIFY,
(DWORD) &mciPlayParameter);

when play to end.
your window will be notified.in your winProc deal with the MCI_NOTIFY message.
or if you use MFC, you need to add a message map of MCI_NOTIFY.

when you want to stop playing.you can send MCI_STOP command.
mciSendCommand(wDeviceID,MCI_STOP,.....);

i hope i can help you . :-)
0
 

Author Comment

by:ryildirim
ID: 1324662
Although this(wyy_cq answer) is something I have tried. But this is a little bit costly for my application. I was looking for an easier/less costly solution)
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1324663
Bought This Question.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now