I have a scenario where I am allocating a chunk of data for audio playback. The audio I'm loading from a MOD(XM/FastTracker2 to be specific) sample data. The trick however is that because the sample data is delta encoded for compression reasons, I now have to go byte-by-byte or word-by-word [size=9px](for 16-bit audio)[/size] through the whole thing and run it through a simple decryption algo.

Here is the algo in semi-Pascal:
[pascal]var
old, new: ShortInt;

old := 0;
for i := 0 to data_len do
begin
new := sample[i] + old;
sample[i] := new;
old := new;
end;[/pascal]

Now how would I best access my audio data considering that I originally allocate and dump it like so...

[pascal] {Sample Data}
for j := NumberOfSamples - XmInstrument.NumOfSamples to NumberOfSamples - 1 do
begin
GetMem(Samples[j].SampleData, Samples[j].SampleLength);

BlockRead(FileStream, Samples[j].SampleData^, Samples[j].SampleLength);
end;[/pascal]

I want to maintain my SampleData pointer as it is so that I can then later give this to whatever audio buffer loading function for OpenAL, DSound, etc... Beyond that I can use whatever additional structures I might need.


EDIT: I guess my original question should have been how can I access a specific piece of the data after allocating it via GetMem().