Playing WAV files consecutively

Please discuss general Delphi programming topics here.

Playing WAV files consecutively

Postby delphi999 » March 19th, 2018, 8:07 pm

I am using Delphi 4. I have multiple WAV files in a resource file and I want to play different combinations of them consecutively, e.g. click a button and play WAV 6, then WAV 2, then WAV 9.

I am using the following code but when I click the Testsound button it will only play the last WAV file.

Can someone help?


procedure TForm1.myPlaySound(mysound: pchar);
var
hFind, hRes: THandle;
SpokenDate: PChar;
begin
hFind := FindResource(HInstance, mysound, 'WAVE') ;
if hFind <> 0 then begin
hRes:=LoadResource(HInstance, hFind) ;
if hRes <> 0 then begin
SpokenDate:=LockResource(hRes) ;
if Assigned(SpokenDate) then SndPlaySound(SpokenDate, snd_ASync or snd_Memory) ;
UnlockResource(hRes) ;
end;
FreeResource(hFind) ;
end;
end;


procedure TForm1.TestsoundClick(Sender: TObject);
begin
myPlaySound('w01o');
myPlaySound('w07Lip');
myPlaySound('w07o');
end;
delphi999
Member
Member
 
Posts: 3
Joined: March 19th, 2018, 7:58 pm

Re: Playing WAV files consecutively

Postby delphi999 » March 20th, 2018, 9:23 pm

I changed snd_async to snd_sync and they all play. The problem is that there is too big a delay between each.

I found another question on this forum about merging WAV files which would solve my problem. I copied the waveaudio files to my delphi bin folder but when I open the sample projects I get 'Error creating form : invalid stream format'.

Do you know why this is?
delphi999
Member
Member
 
Posts: 3
Joined: March 19th, 2018, 7:58 pm

Re: Playing WAV files consecutively

Postby delphi999 » March 24th, 2018, 9:41 am

OK, got things working.
delphi999
Member
Member
 
Posts: 3
Joined: March 19th, 2018, 7:58 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron