I've been use this code to read .wav data in delphi and i've been comparing the result with value i got from matlab function wavread. From which i can say that matlab function can automatically recognize which one is the sample data value, but not with delphi (but both matlab and delphi code result is the same). Since my delphi code cannot recognize the sample data value, i look through the array and found out that the index where sample data value starting were different each .wav file. For an example i test some .wav file and get this:
- classic1.wav the sample data value starting on wavedata[].Data[] index number 40
- classic2.wav the sample data value starting on wavedata[].Data[] index number 35
i got above conclusion by looking at the result y,[y, Fs, nbits, opts]=wavread('classic1.wav','double'); then i go to the result delphi return in an array checking it value and find the exact same value starting in the index 40 for classic1.wav and 35 for classic2.wav. And i want to know if there is a way i can know the starting index of sample data value of each .wav file?
EDIT : i have corrected the record similar to the reference given, it's perfectly right with the header(from ChunkID to Subchunk2size) but i still got confused by the sample data following it because no change from the previous result.
type
TWaveHeader = packed record
Marker_RIFF: array [0..3] of char;
ChunkSize: cardinal;
Marker_WAVE: array [0..3] of char;
Marker_fmt: array [0..3] of char;
SubChunkSize: cardinal;
FormatTag: word;
NumChannels: word;
SampleRate: longint;
ByteRate: longint;
BlockAlign:word;
BitsPerSample: word;
Marker_data: array [0..3] of char;
DataBytes: longint;
end;
TChannel = record
Data : array of smallint;
end;