-1
$\begingroup$

I currently have a 16bit mono file. I would like to read this data to retrieve only the data chunk part and not the entire file with the headers so that I can apply fft on it. I tried finding solutions to read only the data chunk but the codes I managed to find were either not complete / seems to have errors. I am doing this in c#.

$\endgroup$
  • 1
    $\begingroup$ This is off-topic for us since it's about the wav file format (and not the resulting signal processing). Here are a couple SO questions that may be helpful though: Q1 Q2. $\endgroup$ – datageist Jul 3 '13 at 12:35
  • $\begingroup$ @datageist i have tried using the example in the link u provided by apparently the code seems to read in extra data besides the data chunk as i still have many data which contains 0s. If it is possible u can help me look at the code and tell m whats wrong. i have edited to code to look smth like this stackoverflow.com/questions/17416112/… $\endgroup$ – user2431088 Jul 3 '13 at 12:56
1
$\begingroup$

There are libraries to read audio data in many different file formats; such as libsndfile, for which there is a .NET wrapper, too: NLibsndfile. (I don't use .NET/C# and thus have no experience with NLibsndfile.)

$\endgroup$
-2
$\begingroup$

You have to know the format of the header. For example, if it's a RIFF Wave file, the header is always 44 bytes long. You could simply grab every byte beyond 44 without verifying anything. If you're already assuming in your code that the file is 16 bit and mono, then you may as well hard-code the length of the header.

Just hope you won't have to deal with other types of files. ;)

$\endgroup$
  • 4
    $\begingroup$ This is incorrect. Some .wav files, especially in audio production applications, have extra RIFF chunks containing loop points, labels or cues that might appear between the fmt and the data chunks. You can't avoid implementing a RIFF format parser and looking for the proper fmt and data blocks, which is not a very complicated programming task. $\endgroup$ – pichenettes Jul 3 '13 at 14:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.