Hi Hans,
Sorry for the late reply.
On Thu, 17 Aug 2006 01:44:07 -0400 Hans-Christoph Steiner hans@eds.org wrote:
On Jul 31, 2006, at 6:43 AM, Jamie Bullock wrote:
There is an cross-correlation class [cc~] in the flib library,
which you can use to do auto-correlation. It has both a time domain
and a frequency domain CC function. I found the output of the time
domain implementation to be easier to interpret.I've forgotten all my DSP math, could you enlighten me as to how I
might use this?
Auto-correlation is a measure of how much a signal resembles a delayed version of itself. [cc~ <n>] calculates the cross-correlation between the signal at the left inlet, and the signal at the right inlet with delays from -n to +n. If you present the same signal to both inlets you get an auto-correlation. This can be used to detect periodicities (e.g. to extract a periodic signal from a noisy, or detect the fundamental of a sound, where the fundamental is missing) in a signal. The wavelength of the 'extracted' signal is usually taken as the period of the first minimum in the autocorrelation function.
I would not advise you to use [cc~] as it stands. It is under revision at the moment.
There are also number of other feature extraction objects in flib
that might help with what you need, including [peak~], which does
the same as [peakit~] except that with [peak~] the magnitude
spectrum isn't calculated by the object, so you can precalculate
the power spectrum, log mag spectrum, cepstrum and pass it to the
object. With [peak~] you can also set a threshold as a percentage
below the maximum peak found.I checked out [peak~], it looks like its outputting data similar to
what I am looking for, but in a strange format. How can I get just
the frequency of the highest peak? Also, I would like to have much
higher resolution. Is that possible?
Please find attached a patch, which I think demonstrates what you need. It uses [peak~] and [bmax~] to find the frequency of the partial that has the highest amplitude. [peak <n>] outputs the frequencies and amplitudes of the partials that are >=n% of the highest detected peak. Output is audio rate, with each value retaining its FFT bin position within the block. Left outlet gives the frequencies, right outlet gives the respective amplitudes.
The frequency output is fed into [bmax~], the left outlet of which returns the value of the highest value in the block. It returns a list of bins that contain this value from its right outlet. The bin number might be useful in determining whether your detected frequency truly is feedback. For example, you could measure the amount of time for which the bin number of the 'loudest' partial stayed constant. If the partial is above a certain amplitude threshold, and it stays constant for a given period, you can assume that it is feedback and attenuate that frequency in your audio stream with a notch filter.
HTH
Jamie
P.S. I am currently working on a revised version of the library with more features, some of which might prove useful to you.