Data property of TWave has gone?

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

Data property of TWave has gone?

Postby stfine » February 20th, 2009, 10:58 pm

Hello,
I downloaded recent version of your WaveAudio package but the Data property of TWave is missed!

I suppose that it was your deliberate decision to remove it, but it breaks my code written years ago.

:(

What I can write instead of the following where wv1 and wv2 are TWave?
Code: Select all
Move(wv2.Data^, w1^, wv2.DataSize);


Best,
stfine
stfine
Active Member
Active Member
 
Posts: 12
Joined: August 1st, 2006, 7:00 am

Re: Data property of TWave has gone?

Postby Kambiz » February 21st, 2009, 12:05 pm

In the older versions of WaveAudio, TWave was a TMemoryStream but now TWave is a TWaveStreamAdapter.

TWaveStreamAdapter is not a stream but provides a wrapper around any kind of stream to access or modify the wave data. In this case, TWave is a special kind of TWaveStreamAdapter that manipulates a TMemoryStream in behind.

Here is a way to have your old code:

Code: Select all
Move(Pointer(DWORD(TMemoryStream(Wave.Stream).Memory) + Wave.DataOffset)^, w1^, Wave.DataSize);

but it's recommended to use the following code instead:

Code: Select all
if Wave.BeginRead then
begin
  Wave.Read(w1^, Wave.DataSize);
  Wave.EndRead;
end;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: Data property of TWave has gone?

Postby stfine » February 21st, 2009, 8:04 pm

nice, thanks :)
stfine
Active Member
Active Member
 
Posts: 12
Joined: August 1st, 2006, 7:00 am

Re: Data property of TWave has gone?

Postby Kambiz » February 21st, 2009, 9:09 pm

I forgot to mention that if you want to make a copy of a TWave (or genrally TWaveStreamAdapter) instance, you can simply use the Assign method of the target or the AssignTo method of the source.



Code: Select all
SrcWave.AssignTo(DstWave);

OR

DstWave.Assign(SrcWave);
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 2 guests

cron