PannerNode.positionY - Web APIs 编辑

The positionY property of the PannerNode interface specifies the Y coordinate of the audio source's position in 3D Cartesian coordinates, corresponding to the vertical axis (top-bottom). The complete vector is defined by the position of the audio source, given as (positionX, positionY, positionZ), and the orientation of the audio source (that is, the direction in which it's facing), given as (orientationX, orientationY, orientationZ).

Depending on the directionality of the sound (as specified using the attributes coneInnerAngle, coneOuterAngle, and codeOuterGain), the orientation of the sound may alter the perceived volume of the sound as it's being played. If the sound is pointing toward the listener, it will be louder than if the sound is pointed away from the listener.

The AudioParam contained by this property is read only; however, you can still change the value of the parameter by assigning a new value to its AudioParam.value property.

Syntax

var positionY = PannerNode.positionY;

PannerNode.positionY.value = newPositionY;

Value

An AudioParam whose value is the Y coordinate of the audio source's position, in 3D Cartesian coordinates.

Example

The following example starts an oscillator and pans it above the listener after 1 second, below the listener after 2 seconds, and back to the center after 3 seconds. Note that in this case, the change will mainly affect the timbre of the oscillator, as it's a simple mono wave.

const context = new AudioContext();

const osc = new OscillatorNode(context);
const panner = new PannerNode(context);
panner.panningModel = 'HRTF';

panner.positionY.setValueAtTime(1, context.currentTime + 1);
panner.positionY.setValueAtTime(-1, context.currentTime + 2);
panner.positionY.setValueAtTime(0, context.currentTime + 3);

osc.connect(panner)
   .connect(context.destination);

osc.start(0);

Specifications

SpecificationStatusComment
Web Audio API
The definition of 'positionY' in that specification.
Working Draft 

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:54 次

字数:4396

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文