Hey, all -- 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. [example code] <http://pastebin.com/EfRv4HRC> The low-pass filter used in step 3 determines the time-domain weighting for the frequency average. (I recommend a rectangular or triangular average.) Further exercises for the reader: - Advanced differentiation methods may be applied in step 1 to achieve superior accuracy for high-frequency content, or equate the group delay of the A and B signals. - A second-order derivative may be used to compute a standard deviation of frequency content in the signal, handy for controlling filter bandwidth. Lastly, to help readers understand the inaccuracy of the first-difference filter, I've pictured its magnitude response with 1/pi gain below: [image: Inline image 1] (An ideal differentiator would be a straight diagonal line. The "droop" can be rendered almost harmless through oversampling.) Anyway, I hope this is useful to somebody! I've certainly gotten quite a lot of mileage out of it. Evan Balster creator of imitone <http://imitone.com>
_______________________________________________ dupswapdrop: music-dsp mailing list music-dsp@music.columbia.edu https://lists.columbia.edu/mailman/listinfo/music-dsp