使用Web Audio API创建10波段均衡器 [英] Creating a 10-Band Equalizer Using Web Audio API

查看:200
本文介绍了使用Web Audio API创建10波段均衡器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Web Audio API来重新创建类似于
Winamp的10波段均衡器。

I'm trying to wrap my head around using the Web Audio API to recreate something like
Winamp's 10-band equalizer.

< img src =https://cdn.head-fi.org/3/3d/1000x500px-LL-3da00ebd_winamp-eq.pngalt =Winamp的10波段均衡器>

根据我的收集,我必须创建10 Biquad过滤器,将类型设置为 2(对于带通滤波器)并设置其频率分别为 [60,170,310,600,1000,3000,6000,12000,14000,16000] 。一旦我完成了(这里我有点困惑)我会创建一个单独的每个频率band的增益节点并将其值绑定到滑块。

From what I can gather, I have to create 10 Biquad Filters, set their type to 2 (for a Bandpass filter) and set their frequency to [60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000] respectively. Once I have done that (and here's where I'm getting a little confused) I would then create a separate Gain Node for each frequency "band" and bind its value to a slider.

<input id="someFreqBand" type="range" min="-12" max="12" step="0.1" value="0" onchange="slide()"/>

假设所有这些都是正确的,那么剩下的唯一步骤是将所有10个增益节点连接到音频上下文目的地(我想这将占用所有10个频率频段并将它们混合/同步回来)。这是创建Web Audio 10波段均衡器的正确方法吗?

Assuming all of that is correct, then the only remaining step is to connect all 10 gain nodes to the Audio Context destination (which I imagine will take all 10 frequency "bands" and mix/sync them back together). Is this the right way to go about creating a Web Audio 10-band equalizer?

我最担心的是我如何连接源码到10个频段滤波器(+相关增益节点),因为所有节点只有一个输入或输出(包括目的地)。

The major thing I'm confused about is how I go about "connecting" the source to the 10 frequency band filters (+ associated gain node) since all the nodes only have a single input or output (including the destination).

推荐答案

正如Matt D所说,将过滤器连接到同一目的地应该没有问题。

As Matt D said, there should be no problem connecting the filters to the same destination.

但是我会说你可能想要使用类型为5(峰值)的滤波器,这样可以让所有频率通过,只会放大/缩小你的频率。设置相应的filter.frequency.value。这使您可以串联连接滤镜,因此您不需要10个单独的音频路径。您还可以考虑使用低架滤波器作为第一滤波器,使用高架滤波器作为第十滤波器,这在均衡器中相当常见。我不记得是否这就是winamp的作用。

I would however say that you probably want to use filters with type 5 (peaking), which lets all frequencies through and only amplifies/reduce at the frequency at which you've set the respective filter.frequency.value. That lets you connect the filters in series so you don't need 10 separate audio paths. You could also consider using a low-shelf filter as the first filter, and a hi-shelf filter as the tenth, which is rather common in equalizers. I can't remember if that's what winamp does, though.

最后,如果您使用串行峰值滤波器,则不需要单独的增益节点每个频率,您只需为特定过滤器设置filter.gain.value。

Finally, if you go with the peaking filters in series, you don't need a separate gain node for each frequency, you just set the filter.gain.value for the specific filters.

这篇关于使用Web Audio API创建10波段均衡器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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