Using TLiveAudioPlayer and TWaveStorage to play a wav file

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

Using TLiveAudioPlayer and TWaveStorage to play a wav file

Postby MervinG » April 17th, 2008, 4:37 pm

Hi Kambiz,

In this thread, you suggested the following method of supplying the buffer data to the TLiveAudioPlayer component:

Code: Select all
function TForm1.LiveAudioPlayer1DataPtr(Sender: TObject;
  out Buffer: Pointer; var NumLoops: Cardinal;
  var FreeIt: Boolean): Cardinal;
begin
  FreeIt := False;
  Buffer := WaveStorage1.Wave.Data;
  Result := WaveStorage1.Wave.DataSize;
end;



Unfortunately, using v1.87 of your Wave Audio components, WaveStorage1.Wave.Data is invalid. What should I use instead of .Data, please?

Many thanks

Mervin
MervinG
Member
Member
 
Posts: 2
Joined: April 17th, 2008, 4:32 pm

Postby Kambiz » April 17th, 2008, 4:56 pm

In the older versions, TWave was subclassed directly from TMemoryStream. However, in the current version, TWave is subclassed from TWaveStreamAdapter and uses a TMemoryStream to store wave data. So, you can use the following code.

Code: Select all
function TForm1.LiveAudioPlayer1DataPtr(Sender: TObject;
  out Buffer: Pointer; var NumLoops: Cardinal;
  var FreeIt: Boolean): Cardinal;
begin
  FreeIt := False;
  Buffer := TMemoryStream(WaveStorage1.Wave.Stream).Memory;
  Inc(PByte(Buffer), WaveStorage1.Wave.DataOffset);
  Result := WaveStorage1.Wave.DataSize;
end;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby MervinG » April 17th, 2008, 7:43 pm

Thanks very much Kambiz, that is just what I needed.

Out of interest, is there a limit on how many LiveAudioPlayers can be playing a wav sound at any one time? My application is needing to play several sounds, looped, through multiple speakers of multiple sound cards. I intend on having a LiveAudioPlayer component for each sound, directed to the speaker (L or R by the volume) and to the soundcard by DeviceID. I'm wondering if there is a limit per sound card or from Windows?

Mervin
MervinG
Member
Member
 
Posts: 2
Joined: April 17th, 2008, 4:32 pm

Postby Kambiz » April 18th, 2008, 2:28 am

You'we welcome.

I have never tried to play more than two waves simultaneously. On Windows 9x only one wave could be played, but seems XP drivers can mix waves on the fly.

By the way, check out the update. I just uploaded it.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 0 guests

cron