从音频渲染图像
是否可以渲染音频文件的可视化?
也许使用 SoundManager2 / Canvas / HTML5 音频? 你懂一些技术吗?
我想创建这样的东西:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否可以渲染音频文件的可视化?
也许使用 SoundManager2 / Canvas / HTML5 音频? 你懂一些技术吗?
我想创建这样的东西:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
通过 FFT 运行样本,然后将给定频率范围内的能量显示为给定点处的图形高度。您通常希望频率范围从左侧的 20 Hz 左右到右侧的采样率/2 左右(如果采样率超过 40 KHz,则为 20 KHz)。
不过我不太确定是否要在 JavaScript 中执行此操作。不要误会我的意思:JavaScript 完全能够实现 FFT——但我完全不确定是否可以实时实现。 OTOH,对于用户查看来说,每秒更新大约 5-10 次就可以了,这可能是一个更容易达到的目标。例如,每 200 毫秒更新 20 毫秒的样本可能是合理的希望,但我当然不能保证您能够跟上。
Run samples through an FFT, and then display the energy within a given range of frequencies as the height of the graph at a given point. You'll normally want the frequency ranges going from around 20 Hz at the left to roughly the sampling rate/2 at the right (or 20 KHz if the sampling rate exceeds 40 KHz).
I'm not so sure about doing this in JavaScript though. Don't get me wrong: JavaScript is perfectly capable of implementing an FFT -- but I'm not at all sure about doing it in real time. OTOH, for user viewing, you can get by with around 5-10 updates per second, which is likely to be a considerably easier target to reach. For example, 20 ms of samples updated every 200 ms might be halfway reasonable to hope for, though I certainly can't guarantee that you'll be able to keep up with that.
http://ajaxian.com/archives/amazing-audio- Sample-in-javascript-with-firefox
查看源代码以了解他们如何可视化音频
http://ajaxian.com/archives/amazing-audio-sampling-in-javascript-with-firefox
Check out the source code to see how they're visualizing the audio
这还不可能,除非以二进制数据的形式获取音频并解压 MP3(不是 JavaScript 的强项),或者也许使用 Java 或 Flash 提取您需要的信息位(似乎是可能的)但这似乎也比我个人想要承担的更令人头痛)。
但您可能对 Dave Humphrey 的音频实验感兴趣,其中包括一些很酷的可视化内容。他通过修改浏览器源代码并重新编译来做到这一点,因此这对您来说显然不是一个现实的解决方案。但这些实验可能会导致将来向
元素添加新功能。
This isn't possible yet except by fetching the audio as binary data and unpacking the MP3 (not JavaScript's forte), or maybe by using Java or Flash to extract the bits of information you need (it seems possible but it also seems like more headache than I personally would want to take on).
But you might be interested in Dave Humphrey's audio experiments, which include some cool visualization stuff. He's doing this by making modifications to the browser source code and recompiling it, so this is obviously not a realistic solution for you. But those experiments could lead to new features being added to the
<audio>
element in the future.为此,您需要进行傅里叶变换(查找 FFT),这在 javascript 中会很慢,而且目前不可能实时进行。
如果您确实想在浏览器中执行此操作,我建议在 java/silverlight 中执行此操作,因为它们在浏览器中提供最快的数字处理速度。
For this you would need to do a Fourier transform (look for FFT) which will be slow in javascript, and not possible in realtime at present.
If you really want to do this in the browser, I would suggest doing it in java/silverlight, since they deliver the fastest number crunching speed in the browser.
您在这里有一些示例和教程:http://www.html5rocks.com/en/ tutorials/#webaudio
目前,它可以在最后的 Chrome 和最后的 Firefox(Opera?)中运行。
演示:http://www.chromeexperiments.com/tag/audio/
立即执行,对于网站的所有访问者,您可以检查通过 Flash“代理”访问音频数据的 SoundManagerV2.js http://www.schillmania.com/projects/soundmanager2/demo/api/ (他们已经在开发 HTML5 音频引擎,一旦主要浏览器实现它就会发布它)
您可以在画布上绘制 3 种不同的音频数据:波形、均衡器和峰值。
使用 HTML5,您可以获得:
工作时间到了! ;)
You have a tone of samples and tutorials here : http://www.html5rocks.com/en/tutorials/#webaudio
For the moment it work in the last Chrome and the last last Firefox (Opera ?).
Demos : http://www.chromeexperiments.com/tag/audio/
To do it now, for all visitors of a web site, you can check SoundManagerV2.js who pass through a flash "proxy" to access audio data http://www.schillmania.com/projects/soundmanager2/demo/api/ (They already work on the HTML5 audio engine, to release it as soon as majors browsers implement it)
Up to you for drawing in a canvas 3 differents audio data : WaveForm, Equalizer and Peak.
With HTML5 you can get :
Time to work ! ;)