[英]Why is the highest FFT peak not the fundamental frequency of a musical tone?
目前,我正在努力为这个闪烁的小星星文件争取音调。 在大多数情况下,音符的频率是正确的,我们通过变量 index_max 获得。 但是,对于 C5 的音符,它返回的是 C6。 C5 的频率约为 523,而 C6 的频率约为 1046。FFT 告诉我们频率比预期结果高一个八度。 这实际上发生在许多其他文件中,并且似乎注释越低,出现问题的可能性就越大。 任何有关提出此问题或答案的更好方法的说明将不胜感激!
import scipy.io.wavfile as wave
import numpy as np
from frequencyUtil import *
from scipy.fft import fft, ifft
def read_data(scale):
infile = "twinkle.wav"
rate, data = wave.read(infile)
sample_rate = int(rate/scale)
time_frames = [data[i:i + sample_rate] for i in range(0, len(data), sample_rate)]
notes = []
for x in range(len(time_frames)): # for each section, get the FFT
if(type(data[0]) is np.int16): # If not dual channel process like normal
dataZero = np.array(time_frames[x])
else: # if is dual channel get first ele of every list
data = np.array(time_frames[x]) # convert to np array
dataZero = [row[0] for row in data]
frequencies = fft(dataZero) # get the FFT of the wav file
inverse = ifft(np.real(frequencies))
index_max = np.argmax(np.abs(frequencies[0:8800//scale])) # get the index of the max number within music range
#print(abs(frequencies[index_max]))
# filters out the amplitudes that are lower than this value found through testing
# should eventually understand the scale of the fft frequencies
if(abs(frequencies[index_max]) < 4000000/scale):
continue
index_max = index_max*scale
print(index_max)
notes.append(index_max)
return notes```
许多音高的声音(尤其是低音)在频谱中具有比基本音高更强的泛音或谐波。 这些泛音使乐器或声音听起来比正弦波发生器更有趣。 但由于音高是一种心理声学现象,人脑会做出必要的修正来感知音高。
因此,FFT 幅度矢量中最强的频谱峰值通常不在基频处,因为音调具有非平凡的频谱。
有大量关于音高检测和估计问题的学术论文和文章。 许多使用倒谱/倒谱、自相关、机器学习等方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.