Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!

The StereoPannerNode interface of the Web Audio API represents a simple stereo panner node that can be used to pan an audio stream left or right. It is an AudioNode audio-processing module that positions an incoming audio stream in a stereo image using a low-cost equal-power panning algorithm.

The pan property takes a unitless value between -1 (full left pan) and 1 (full right pan). This interface was introduced as a much simpler way to apply a simple panning effect than having to use a full PannerNode.

Number of inputs 1
Number of outputs 1
Channel count mode "clamped-max"
Channel count 2
Channel interpretation "speakers"

Properties

Inherits properties from its parent, AudioNode.

StereoPannerNode.pan Read only
Is an a-rate AudioParam representing the amount of panning to apply.

Methods

No specific method; inherits methods from its parent, AudioNode.

Example

In our StereoPannerNode example (see source code) HTML we have a simple <audio> element along with a slider input to increase and decrease pan value. In the JavaScript we create a MediaElementAudioSourceNode and a StereoPannerNode, and connect the two together using the connect() method. We then use an oninput event handler to change the value of the StereoPannerNode.pan parameter and update the pan value display when the slider is moved.

Moving the slider left and right while the music is playing pans the music across to the left and right speakers of the output, respectively.

var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var myAudio = document.querySelector('audio');

var panControl = document.querySelector('.panning-control');
var panValue = document.querySelector('.panning-value');

pre.innerHTML = myScript.innerHTML;

// Create a MediaElementAudioSourceNode
// Feed the HTMLMediaElement into it
var source = audioCtx.createMediaElementSource(myAudio);

// Create a stereo panner
var panNode = audioCtx.createStereoPanner();

// Event handler function to increase panning to the right and left
// when the slider is moved

panControl.oninput = function() {
  panNode.pan.value = panControl.value;
  panValue.innerHTML = panControl.value;
}

// connect the AudioBufferSourceNode to the gainNode
// and the gainNode to the destination, so we can play the
// music and adjust the panning using the controls
source.connect(panNode);
panNode.connect(audioCtx.destination);

Specifications

Specification Status Comment
Web Audio API
The definition of 'StereoPannerNode' in that specification.
Working Draft Initial definition

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 41.0  37.0 (37.0)  Not supported Not supported Not supported
Feature Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support Not supported 37.0 2.2 Not supported Not supported Not supported (Yes)

See also

문서 태그 및 공헌자

 이 페이지의 공헌자: fscholz, Sebastianz, jpmedley, chrisdavidmills, teoli
 최종 변경: fscholz,