[name]

创建AudioAnalyser对象, 使用[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode AnalyserNode] 去分析音频数据.

使用了 [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].

代码示例

// create an AudioListener and add it to the camera const listener = new THREE.AudioListener(); camera.add( listener ); // create an Audio source const sound = new THREE.Audio( listener ); // load a sound and set it as the Audio object's buffer const audioLoader = new THREE.AudioLoader(); audioLoader.load( 'sounds/ambient.ogg', function( buffer ) { sound.setBuffer( buffer ); sound.setLoop(true); sound.setVolume(0.5); sound.play(); }); // create an AudioAnalyser, passing in the sound and desired fftSize const analyser = new THREE.AudioAnalyser( sound, 32 ); // get the average frequency of the sound const data = analyser.getAverageFrequency();

例子

[example:webaudio_sandbox webaudio / sandbox ]
[example:webaudio_visualizer webaudio / visualizer ]

构造函数

[name]( audio, [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize fftSize] )

创建[page:AudioAnalyser AudioAnalyser].

属性

[property:AnalyserNode analyser]

[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode AnalyserNode]用来分析音频数据.

[property:Integer fftSize]

2的幂次方最高为2048, 用来表示确定频域的FFT (傅立叶变换)大小. 这个[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize page]有详细信息.

[property:Uint8Array data]

用来分析数据的Uint8Array的大小由[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount analyser.frequencyBinCount] 确定.

方法

[method:Uint8Array getFrequencyData]()

使用网络音频的[link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData getByteFrequencyData] 方法. 看这个页面.

[method:Number getAverageFrequency]()

通过方法[page:AudioAnalyser.getFrequencyData getFrequencyData]获取平均频率.

源码

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]