How to retrieve frame number and frame size from wav file

4k views Asked by At

I'm currently doing a thesis about chord recognition with EPCP with wav file as an input, but now I'm stuck at determining number of frames and frame size of a single wav file. I need those data as the parameters for hammingwindow function in NAudio library

public static double HammingWindow(int n, int frameSize)

I've retrieved all available wav headers, but I dont know how to get number of frames and frame size. Can I calculate it from given header data? Or is there another way?

3

There are 3 answers

0
gnyrfta On

I have not used HammingWindow. A frame according to this is like a sample, but for multichannel format "a snapshot of all the channels at a specific data point".

You can get the sample size using something like this from the header, if that is actually what you want.

0
guitarflow On

If you were aware of what a hamming-window is, you would not ask a question like that. The wikipedia article tells you everything about it.

I myself am not an expert in DSP but I've been working with it for a few months now in my spare time. Everything I can tell you is that this is an absolutely complicated field! Nothing you can grasp in a week or so. Students get educated in this field for several semesters in high school. Just as a side note.

So, regarding your question :

You choose a block size, this is usually predetermined from your audio hardware. This always has a base of 2, so 128, 256 .... a typical one is 1024. This is your framesize.

When using WAV files, you can choose the framesize as you want. It should just meet the above mentioned criteria.

A window in this context is a "curve" that starts at time 0 with some value and ends at frameSize-1 with some value.

The parameter "n" of your function is the position within this window. The function returns a value between 0 and 1, which represents the value at "n".

0
Lex Li On

NAudio has a WPF demo in which SampleAggregator.cs uses HammingWindow function. Did you check that sample and understand how it is used?