## Accessing WAVE data values

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

### Accessing WAVE data values

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);
for i := 0 to byteTally-1 do
showMessage(intToStr(buffer[i]));

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.

Thanks
Paul
PalmiePaul
Member

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

### Re: Accessing WAVE data values

The Read method of Stream class requires a const argument but you passed a pointer. Try this:
Code: Select all
byteTally := wave.stream.read(buffer[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.
Kambiz

Kambiz