音乐样本中的和声计数
为了确定声音的丰富度,我想确定音乐样本中的和声数量。为此,我将Processing与Minim库一起使用,它为我提供了FFT的完整频谱。我想知道如何计算FFT产生的频谱中的所有峰值,我什至对基频不感兴趣。
To determine the richness of a sound, I would like to determine the number of harmonics in a sample of music. For that, I'm using Processing with the Minim library which gives me a full spectrum with a FFT. I'm wondering how to count all the peaks in the spectrum produced by the FFT, I'm not even interested in the fundamental frequency.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的需要,有多种方法可以实现此目的。
如果您想计算每个峰值,那么您应该迭代频谱中的所有频率,记住强度是增加还是减少。每当您注意到方向从增加到减少的变化时,您就会增加峰值计数器。但请注意,这也将包括非常微弱的峰值,这可能是也可能不是您需要的。您可以对要记录的峰值必须发生的增加和减少量设置最低限制。
或者,您可以找到信号强度的基线(在最简单的情况下使用平均值),然后计算正异常值的数量(与基线有一些可配置的最小偏差)。如果您修改此方法以使用频率相关的基线和最小值来解释较高频率下强度的逐渐下降,您可能会获得更好的结果(同样,这取决于您的特定信号和需要,这是否有用)。一种简单的方法是将频谱划分为多个频段(足够小,以便能够在每个频段中假设或多或少平坦的能量分布),并为每个频段使用不同的基线和最小值。
There are many ways of accomplishing this depending on your needs.
If you want to count every peak then you should iterate through all the frequencies in the spectrum remembering whether intensity has been increasing or decreasing. Every time you notice the change in direction from increase to decrease you increment the peak counter. Note however that this will include very faint peaks as well which may or may not be what you need. You can put a minimum limit on how much of an increase and decrease has to happen for a peak to be registered.
Alternatively, you can find a baseline for your signal's intensity (using average in the simplest case) and then count the number of positive outliers (with some configurable minimum deviation from the baseline). You probably will get better results if you modify this approach to use frequency-dependent baseline and minimum to account for gradual drop in intensity at higher frequencies (again, it depends on your particular signal and needs whether this would be useful). One simple way of doing this is to divide your spectrum into bands (small enough to be able to assume more or less flat energy distribution throughout each band) and use different baseline and minimum for each band.