WebAudio 改变 Listener 和/或 Panner 的方向 [英] WebAudio changing of orientation of Listener and/or Panner

查看:13
本文介绍了WebAudio 改变 Listener 和/或 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.setOrientationthis.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屋!

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