Download node_modules/three/src/audio/AudioAnalyser.js from SimWorld-AI/industrial-harbor-viewer: direct link, hf CLI and curl.
- Browser
- Download file 591 Bytes
-
https://huggingface.co/spaces/SimWorld-AI/industrial-harbor-viewer/resolve/main/node_modules/three/src/audio/AudioAnalyser.js
- Command line
-
hf download hf://spaces/SimWorld-AI/industrial-harbor-viewer/node_modules/three/src/audio/AudioAnalyser.js
-
curl -L -o AudioAnalyser.js https://huggingface.co/spaces/SimWorld-AI/industrial-harbor-viewer/resolve/main/node_modules/three/src/audio/AudioAnalyser.js
591 Bytes
| class AudioAnalyser { | |
| constructor( audio, fftSize = 2048 ) { | |
| this.analyser = audio.context.createAnalyser(); | |
| this.analyser.fftSize = fftSize; | |
| this.data = new Uint8Array( this.analyser.frequencyBinCount ); | |
| audio.getOutput().connect( this.analyser ); | |
| } | |
| getFrequencyData() { | |
| this.analyser.getByteFrequencyData( this.data ); | |
| return this.data; | |
| } | |
| getAverageFrequency() { | |
| let value = 0; | |
| const data = this.getFrequencyData(); | |
| for ( let i = 0; i < data.length; i ++ ) { | |
| value += data[ i ]; | |
| } | |
| return value / data.length; | |
| } | |
| } | |
| export { AudioAnalyser }; | |