【发布时间】:2020-06-08 15:13:43
【问题描述】:
我为一个游戏制作了一个网站来制作唱片和分享音乐,一些用户问我是否可以添加一个混响选项来打开/关闭混响(这可以模拟在洞穴中),我搜索了一下,然后found about the webAudio api reverb with the convolver node. 老实说,我对此不太了解,但我试图让它发挥作用,最后我做到了:
const source = a_ctx.createBufferSource()
source.buffer = buf
source.playbackRate.value = pitchKey;
if(reverbToggled){
let convolver = a_ctx.createConvolver();
convolver.buffer = buf
source.connect(convolver)
convolver.connect(a_ctx.destination)
}else{
source.connect(a_ctx.destination)
}
source.start(0)
变量“buf”是解码后的音频文件,它似乎确实可以工作,但它确实响亮且失真,我有一个演示here,要查看开/关混响之间的区别,只需按“R”按钮,然后按中间的笔记按钮。
有可能我在 convolverNode 的实现中犯了一些错误,但我不知道是什么原因造成的,我该如何解决?
【问题讨论】:
标签: javascript audio web-audio-api