Accessing WAVE data values

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

Accessing WAVE data values

Postby PalmiePaul » January 24th, 2013, 7:52 am

Hi there
I have an application that requires me to edit the individual PCM data values in a WAVE file. I have written the following code
wave := tWave.create;
setLength(buffer, 4);
byteTally :=, 4);
for i := 0 to byteTally-1 do

If I’ve understood correctly, this should output the first four data bytes from the WAVE file. Clearly, I haven’t understood correctly, because the showmessage causes an access violation error. Can you tell me why?

At a more global level, does your package have some way of getting the data values out of the file as integers? Even if I manage to fix the code above, I don’t really want to have to assemble bytes that represent two’s complement numbers into integers.

Posts: 1
Joined: January 24th, 2013, 7:46 am

Re: Accessing WAVE data values

Postby Kambiz » January 24th, 2013, 4:55 pm

The Read method of Stream class requires a const argument but you passed a pointer. Try this:
Code: Select all
byteTally :=[0], 4);

To read wave data as integer values, you just need to define you buffer as array of integers. In this case just remember to pass the appropriate value for the Count parameter of the Stream.Read method.
User avatar
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