4

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?

Xan
  • 74,770
  • 16
  • 179
  • 206
Norman Pratama
  • 67
  • 2
  • 12
  • There is no such thing as a frame or frame size in wav files. Are you talking about samples, bit rates etc.? – Daniel Hilgarth Jan 18 '12 at 11:59
  • well I might have misunderstood about this. I'm new in signal processing. I've got the sample rates,bit rates,channels, etc , since they are all included in the wav header. If frame data doesnt exist in wav, can I split wav files into frames? – Norman Pratama Jan 18 '12 at 12:06
  • As I already said, there is no such thing as a "frame" in wave. This concept is simply not known. A frame exists in video but not in audio. What are you talking about when you say "frame"? – Daniel Hilgarth Jan 18 '12 at 12:08
  • Well actually I need "frames" because in someone's journal which I'm using as my reference said, "first, detect signal's peak threshold and sample every frame in a given interval time. After that, a windowing is applied to smooth peak signal in every frame". Thats why I need to know to get frames in wav.. Do I just need to split it? – Norman Pratama Jan 18 '12 at 12:37
  • I don't know enough about signal processing to answer that for sure, but it sounds as if you could simply split it, yes. You need to try it and see if it leads to the desired result - or hope someone with more knowledge about signal processing stumbles over your question... – Daniel Hilgarth Jan 18 '12 at 12:42
  • you usually apply the Hamming window because you are about to apply an FFT. The frame size is your choice, but must be a power of 2 (1024 is a common choice). The higher the frame size, the greater the frequency resolution of the FFT, but also the greater time period you are measuring. – Mark Heath Jan 18 '12 at 16:45

3 Answers3

2

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".

guitarflow
  • 2,930
  • 25
  • 38
1

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.

gnyrfta
  • 95
  • 10
1

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

Lex Li
  • 60,503
  • 9
  • 116
  • 147