Page 1 of 1

Data property of TWave has gone?

PostPosted: February 20th, 2009, 10:58 pm
by stfine
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

Re: Data property of TWave has gone?

PostPosted: February 21st, 2009, 12:05 pm
by Kambiz
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;

Re: Data property of TWave has gone?

PostPosted: February 21st, 2009, 8:04 pm
by stfine
nice, thanks :)

Re: Data property of TWave has gone?

PostPosted: February 21st, 2009, 9:09 pm
by Kambiz
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);