I need to read a wav file to an array, do some analysis of the PCM samples, and output an xml report. The wav file is mono 16 bit PCM at 48000 samples/sec, size around 500MB.
I can handle everything except getting the wav file to an array. Array will be dynamic of Int16.
My issue is properly parsing the wav file before storing the sample data to the array. I only need the sample data (no need to save header or subchunk info anywhere).
I carefully read the following webpage and took note of the extra subchunks one must parse when reading a wav file. I noted that headers are sometimes not 44 bytes. How does one handle that? Presumably after reading the header, one is looking for subchunks and data. What exactly defines a subchunk? What does one do with that subchunk info?
https://stackoverflow.com/questions/8754111/how-to-read-the-data-in-a-wav-file-to-an-arrayThe use of an audio library is mentioned to simplify things. Thus I have studied the UOS, BASS, and ACS libraries and they all seem to hide the data buffer for direct access (or make access slow- BASS appears to have lots of overhead accessing samples).
I don't need to play, manipulate, or save the wav file. I only need to do some special analysis of the PCM samples that are in the array. It may take thousands of iterations of the 500MB of data to find what I'm looking for, thus I need the whole file in RAM if I want to have it finish running before I die.
I have many years of experience writing parsers in Delphi and Lazarus, but need to know specifics of what I'm parsing. I have studied several C, C++, and C# RIFF parsers, but none output data, or handle extra subchunks. I have attempted to study the source code for UOS and ACS to find the RIFF parser, but the complexity of the code makes for a very steep learning curve.
I have no problem using a command line program to parse the wav and save the raw PCM to a file (I do know how to read that to an array). I found Sox, but it doesn't seem to have the ability to output raw PCM (no headers or subchunks).
I have Lazarus 2.0.6 running on a Windows 7 Pro 64bit PC with 64GB ECC RAM.
Can anyone help?