安卓:从FFT到音符得到映射频率 [英] Android : Mapping frequency obtained from FFT to musical notes
问题描述
开发它映射的乐器弹奏的音符的应用程序。例如: - 如果C是钢琴演奏,应用程序显示一个C
Developing an application which maps the note played on an instrument. Example:- If a C is played on the piano, the application displays a C.
double [] notes={16.35,17.32,18.35,19.45,20.6,21.83,23.12,24.5,25.96,27.5,29.14,30.87};
char [] notations={'c','C','d','D','e','f','F','g','G','a','A','b'};
int index=0;
double minvalue=999999;
if(values[0]>16.34){
for (int i=0;i<=11;i++)
{
double result=values[0]%notes[i];
if(result==0)
{
index=i;
break;
}
double temp=notes[i]-result;
if(temp<minvalue)
{
minvalue=temp;
index=i;
}
}
TextView display2 = (TextView) findViewById(R.id.textView2);
display2.setText(String.valueOf(notations[index]));
笔记阵列由十二个不同的音符的频率。
值[0]由其中获得的频率。
值[0]%笔记[i]的用于确定频率属于最接近音符
notes array consists of the frequencies of the twelve different notes. value[0] consists of the frequency which is obtained. value[0]%notes[i] is used to determine the closest note the frequency belongs to.
问题:
中的值发生很大的变化!
由于其中,当C是在钢琴上演奏,它集在C,但qucikly其他一些不是因为改变值的变化。
The values change a lot! Because of which, when C is played on the piano, It sets on C, but changes qucikly to some other not because of the changing values.
有没有更好的映射方案可以遵循?
Is there a better mapping scheme which can be followed?
推荐答案
您应该寻找基音检测算法
真实世界的声音是不是静态的。每个泛音的相对强度可以在不同的速率随时间而改变。在给定时刻,声音的基本频率可以从FFT峰值幅度不同。
Real-world sounds are not static. Relative intensity of each overtone may change at different rate over time. The fundamental frequency of a sound at given moment can be different from FFT peak magnitude.
P.S。发现多个COM prehensive答案
这篇关于安卓:从FFT到音符得到映射频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!