sample buffering; when and how to clear?

Mar 23, 2012 at 6:52 PM

Your documentation states that if there are not enough samples to detect a pitch, future calls will append to the list of samples passed in on the previous call.  This brings up several questions:

1. How many samples do I need to detect any pitch in your supported range (between 50Hz and 1.6KHz) ? Is 441 samples with a sample rate of 44100/s sufficient?

2. If I don't want you to store any samples from my previous detection all, how do I clear the buffer or disable that feature?

3. Is the data passed into the ProcessBuffer method destroyed or modified in any way?

Mar 24, 2012 at 5:19 PM

1. The number of samples is derived from the sampling frequency and the minimum detection frequency. If you look at PitchTracker.Setup, you will see a formula that is used there to calculate m_pitchBufSize. In addition, there is also a m_detectOverlapSamples value that is also calculated in that method. That value is added to m_pitchBufSize. For 44100 samplerate and the default 50Hz min frequency, these values correspond to 1780 and 220, so the minimum required samples is 2000.

It should be easy to add a property like PitchTracker.MinRequiredSamples that simply returns m_pitchBufSize + m_detectOverlapSamples. There is already one called PitchTracker.DetectSamplesOffset that will return half that value, which is used to calculate the offset from the input signal to the detected value (which can be used to sync up the detected pitch with the passed in waveform). If you don't want to add a new property, then PitchTracker.DetectSampleOffset multiplied by 2 will give you the minimum number of required samples.

2. You can clear the buffer by calling PitchTracker.Reset(). You can't disable the feature, since it is an integral part of how PitchTracker works. If you are always going to pass in one large buffer, then one can certainly modify the code such that it doesn't use the intermediate circular buffer. But this will require a lot of changes and I don't think a lot of people would really need that. If this is something you absolutely require, then you would probably need to make the changes on your end.

3. No, the data is filtered and copied into the intermediate circular buffers. The data in the original buffer is untouched.

Mar 25, 2012 at 3:10 AM

Thanks for the info on the buffer size. I did see the Reset method shortly after I made this post. It seems to do exactly what I was after there.

Jun 23, 2014 at 7:45 AM
Edited Jun 23, 2014 at 7:45 AM
sir I am new in signal processing please tel me who i put the wave file in for processing... please reply as soon as possible....
thanks in advance....