well, i remember a paper from long ago from James Beauchamp where he defines spectral centroid as � � SUM{ |c_n| n } / SUM{ |c_n| } � where c_n is the complex Fourier coefficient for the nth harmonic. �if you wanted to base it on energy � � SUM{ |c_n|^2 n } / SUM{ |c_n|^2 } � it will give you the harmonic number (in fractional form) where the centroid of magnitude or magnitude-squared (which is energy) is. note that this expression is independent of the fundamental frequency, f0. � � ---------------------------- Original Message ---------------------------- Subject: [music-dsp] Cheap spectral centroid recipe From: "Evan Balster" <e...@imitone.com> Date: Mon, February 1, 2016 1:41 pm To: music-dsp@music.columbia.edu -------------------------------------------------------------------------- > > First posting here. I'm an outsider to the DSP world, but I do quite a lot > of DSP research and development. In the course of my work I have turned up > a number of simple tricks which I imagine would prove handy to other > developers. I have combed through a handful of classic music-dsp > discussions (eg. pink noise generation) and I get the idea that sharing > techniques is encouraged here -- so I would like to make a habit of doing > this. > > > To that end: A handy, cheap algorithm for approximating the power-weighted > spectral centroid -- a signal's "mean frequency" -- which is a good > heuristic for perceived sound brightness > <https://en.wikipedia.org/wiki/Brightness#Brightness_of_sounds>. In spite > of its simplicity, I can't find any mention of this trick online -- the > literature almost always prescribes FFT. > > 1. Apply a first-difference filter to input signal A, yielding signal B. > 2. Square signal A, yielding signal AA; square signal B, yielding signal > BB. > 3. Apply a low-pass filter of your choice to AA, yielding PA, and BB, > yielding PB. > 4. Divide PB by PA, then multiply the result by the input signal's > sampling rate divided by pi. > i *think* what that will get you is � SUM{ |c_n|^2 f0^2 n^2 } / SUM{ |c_n|^2 } � and it will be proportional to the square of frequency. �is that what you want? � what if the first-difference filter (which is + 6 dB/oct) was replaced by an inverse pinking filter (which is +3 dB/oct) and you did that? �then the centroid measure would be proportional to frequency but still be based on energy. �you would still have to divide by f0 (requiring a pitch detector) to make it independent of the fundamental frequency and dependent only on the waveshape. � > [example code] <http://pastebin.com/EfRv4HRC> > � i'll look at it. thanks Evan. -- � r b-j � � � � � � � � � r...@audioimagination.com � "Imagination is more important than knowledge."
_______________________________________________ dupswapdrop: music-dsp mailing list music-dsp@music.columbia.edu https://lists.columbia.edu/mailman/listinfo/music-dsp