You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.0 KiB
101 lines
3.0 KiB
2 years ago
|
<!DOCTYPE html>
|
||
|
<html lang="fr">
|
||
|
<head>
|
||
|
<meta charset="utf-8" />
|
||
|
<base href="../../../" />
|
||
|
<script src="page.js"></script>
|
||
|
<link type="text/css" rel="stylesheet" href="page.css" />
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1>[name]</h1>
|
||
|
|
||
|
<p class="desc">
|
||
|
Crée un objet AudioAnalyser, qui utilise un [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode AnalyserNode]
|
||
|
afin d'analyser les données audio.<br /><br />
|
||
|
|
||
|
La [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API] est utilisée.
|
||
|
|
||
|
</p>
|
||
|
|
||
|
<h2>Exemple de Code</h2>
|
||
|
|
||
|
<code>
|
||
|
// 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();
|
||
|
</code>
|
||
|
|
||
|
<h2>Exemples</h2>
|
||
|
|
||
|
<p>
|
||
|
[example:webaudio_sandbox webaudio / sandbox ]<br />
|
||
|
[example:webaudio_visualizer webaudio / visualizer ]
|
||
|
</p>
|
||
|
|
||
|
<h2>Constructeur</h2>
|
||
|
|
||
|
|
||
|
<h3>[name]( audio, [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize fftSize] )</h3>
|
||
|
<p>
|
||
|
Crée un nouvel [page:AudioAnalyser AudioAnalyser].
|
||
|
</p>
|
||
|
|
||
|
|
||
|
<h2>Propriétés</h2>
|
||
|
|
||
|
<h3>[property:AnalyserNode analyser]</h3>
|
||
|
<p>Un [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode AnalyserNode] utilisé pour analyser l'audio.</p>
|
||
|
|
||
|
<h3>[property:Integer fftSize]</h3>
|
||
|
<p>
|
||
|
Une puissance de deux non-nulle inférieure ou égale à 2048, représentant la taille de la FFT (Fast Fourier Transform - Transformation de Fourier Rapide) à utiliser pour déterminer le domaine de fréquence.
|
||
|
Consulter [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize cette page] pour obtenir plus de détails.
|
||
|
</p>
|
||
|
|
||
|
<h3>[property:Uint8Array data]</h3>
|
||
|
<p>
|
||
|
Un Uint8Array avec une taille determinée par [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount analyser.frequencyBinCount]
|
||
|
utilisé pour stocker les données d'analyse.
|
||
|
</p>
|
||
|
|
||
|
|
||
|
<h2>Méthodes</h2>
|
||
|
|
||
|
|
||
|
<h3>[method:Uint8Array getFrequencyData]()</h3>
|
||
|
<p>
|
||
|
Utilise la méthode [link:https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData getByteFrequencyData] de l'API Web Audio.
|
||
|
Voir cette page.
|
||
|
</p>
|
||
|
|
||
|
<h3>[method:Number getAverageFrequency]()</h3>
|
||
|
<p>
|
||
|
Recupère la moyenne des fréquences retournées par la méthode [page:AudioAnalyser.getFrequencyData getFrequencyData].
|
||
|
</p>
|
||
|
|
||
|
<h2>Source</h2>
|
||
|
|
||
|
<p>
|
||
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
||
|
</p>
|
||
|
</body>
|
||
|
</html>
|