Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Playing multiple wav files sequentially while waiting for user input

Posted on 1998-11-13
7
199 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 94
Turn a spreadsheet into a vba executable. 2 91
Best tools for Backup and restore of Wordpress site 6 57
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 102
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

791 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