Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to play two sounds simultaneously Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Multimedia
Language
Delphi 2.x
Views
76
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I'd like to have a background.wav file playing and once in a while have a short 
effects .wav sound play at the same time (without interrupting - stopping and 
restarting it - the background .wav).

Answer:

The Delphi code below plays two sounds concurrently under Win95. I think concurrent 
sound playing relies on the driver supporting multiple inputs, and I believe you 
could request if it has this capability before trying to play.


1   procedure TForm1.Button1Click(Sender: TObject);
2   begin
3     SendMCICommand('open waveaudio shareable');
4     SendMCICommand('play hickory.wav');
5     SendMCICommand('play greeting.wav');
6     SendMCICommand('close waveaudio');
7   end;
8   
9   procedure TForm1.SendMCICommand(Cmd: string);
10  var
11    RetVal: integer;
12    ErrMsg: array[0..254] of char;
13  begin
14    RetVal := mciSendString(StrAsPChar(Cmd), nil, 0, 0);
15    if RetVal <> 0 then
16    begin
17      {get message for returned value}
18      mciGetErrorString(RetVal, ErrMsg, 255);
19      MessageDlg(StrPas(ErrMsg), mtError, [mbOK], 0);
20    end;
21  end;
22  
23  function StrAsPChar(var S: OpenString): PChar;
24  {returns a PChar from a string}
25  begin
26    if Length(S) = High(S) then
27      dec(S[0]);
28    S[Ord(Length(s)) + 1] := #0;
29    Result := @S[1];
30  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC