Page 1 of 1

Playing WAV files consecutively

PostPosted: March 19th, 2018, 8:07 pm
by delphi999
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;

Re: Playing WAV files consecutively

PostPosted: March 20th, 2018, 9:23 pm
by delphi999
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?

Re: Playing WAV files consecutively

PostPosted: March 24th, 2018, 9:41 am
by delphi999
OK, got things working.