有没有一种方法可以检测HTML 5 Web音频API中的音频频率? [英] Is there a way to detect audio frequency in HTML 5 web audio API?

查看:116
本文介绍了有没有一种方法可以检测HTML 5 Web音频API中的音频频率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有一种方法可以检测HTML 5 Web音频中麦克风的音频频率.我希望制作一个在线吉他调音器,并且需要从声音输入中获得以赫兹为单位的音频频率.我已经看到了一些EQ和滤镜效果,但没有看到关于频率识别的任何信息.

I would like to know is there a way we can detect audio frequency from microphone in html 5 web audio. I wish to make an online guitar tuner, and I need to have the audio frequency in hertz, from the sound input. I've seen some EQ and filters effects, but I didn't see anything about frequency recognition.

我发现了这一点: http://www.smartjava.org/content /exploring-html5-web-audio-visualizing-sound 第二点(分析器节点)非常有趣.我看到了他的源代码,但是我不知道如何将分析仪连接到麦克风输入. 当mp3文件开始播放时,他调用playSound()函数,并在那里绘制画布.但是我没有像playSound()这样的函数...

I found this: http://www.smartjava.org/content/exploring-html5-web-audio-visualizing-sound The 2nd point (analyser node) is really interesting. I seen his source code, but I can't figure how to connect the analyser to the microphone input. He calls a playSound() function when the mp3 file starts to play, and there he draws his canvas. But I do not have a playSound() like function...

推荐答案

我写了一个网络音频库,除其他外,它可以从麦克风输入中检测频率.在 https://github.com/rserota/wad#pitch-detection 中进行检查.

I wrote a web audio library which, among other things, can detect frequency from mic input. Check it out at https://github.com/rserota/wad#pitch-detection

var voice = new Wad({source : 'mic' });
var tuner = new Wad.Poly();
tuner.add(voice);
voice.play();

tuner.updatePitch() // The tuner is now calculating the pitch and note name of its input 60 times per second. These values are stored in tuner.pitch and tuner.noteName.

var logPitch = function(){
    console.log(tuner.pitch, tuner.noteName)
    requestAnimationFrame(logPitch)
};
logPitch();
// If you sing into your microphone, your pitch will be logged to the console in real time.

tuner.stopUpdatingPitch(); // Stop calculating the pitch if you don't need to know it anymore.

这篇关于有没有一种方法可以检测HTML 5 Web音频API中的音频频率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆