WebAudio 改变 Listener 和/或 Panner 的方向 [英] WebAudio changing of orientation of Listener and/or Panner
问题描述
我想了解 WebAudio API 的工作原理.我有两个对象;一个代表听者,一个代表源.并使用以下链接作为示例.我可以移动音源,声音位置也会改变.
I am trying to understand how the WebAudio API would work. I have two objects; one representing the listener and one the source. And have used the below link as an example. I am able to move the source and the sound position changes.
https://mdn.github.io/webaudio-examples/panner-节点/
已提供更改方向的命令:即this.panner.setOrientation
或this.listener.setOrientation
.我的问题是:如果我有一个源或侦听器对象(在画布模式下使用 ThreeJS 即我们知道它的位置和旋转)我如何通过 JS 更改平移器或侦听器的方向(视情况而定).
The command to change the orientation has been provided: viz this.panner.setOrientation
or this.listener.setOrientation
. The question I have is: if I have a source or listener object (in canvas mode using ThreeJS viz. we know its position and rotation) how do I change the orientation of either the panner or listener (as the case may be) via JS.
一个例子会很有帮助.谢谢
An example would greatly help. Thanks
推荐答案
有什么理由不使用 THREE 的 PositionalAudio 对象吗?https://threejs.org/docs/index.html#api/audio/位置音频.这使您可以向网格对象添加声音,并且三个将负责移动它.如果您想获取与 AudioBuffer 不同的声音,只需将音频源连接到 PositionalAudio 对象的 .gain.
Any reason not to use THREE's PositionalAudio object? https://threejs.org/docs/index.html#api/audio/PositionalAudio. That lets you add a sound to mesh object, and THREE will take care of moving it. If you want to source a different sound than an AudioBuffer, just connect the audio source to the .gain of the PositionalAudio object.
这篇关于WebAudio 改变 Listener 和/或 Panner 的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!