Skip to content

Commit 7353094

Browse files
authored
Merge pull request mrdoob#19975 from ianpurvis/audio-analyser-es6-class
AudioAnalyser: Convert to es6 class
2 parents 1e2e75e + 2ea6a9a commit 7353094

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/audio/AudioAnalyser.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
function AudioAnalyser( audio, fftSize ) {
1+
class AudioAnalyser {
22

3-
this.analyser = audio.context.createAnalyser();
4-
this.analyser.fftSize = fftSize !== undefined ? fftSize : 2048;
3+
constructor( audio, fftSize ) {
54

6-
this.data = new Uint8Array( this.analyser.frequencyBinCount );
5+
this.analyser = audio.context.createAnalyser();
6+
this.analyser.fftSize = fftSize !== undefined ? fftSize : 2048;
77

8-
audio.getOutput().connect( this.analyser );
8+
this.data = new Uint8Array( this.analyser.frequencyBinCount );
99

10-
}
10+
audio.getOutput().connect( this.analyser );
11+
12+
}
1113

12-
Object.assign( AudioAnalyser.prototype, {
1314

14-
getFrequencyData: function () {
15+
getFrequencyData() {
1516

1617
this.analyser.getByteFrequencyData( this.data );
1718

1819
return this.data;
1920

20-
},
21+
}
2122

22-
getAverageFrequency: function () {
23+
getAverageFrequency() {
2324

2425
let value = 0;
2526
const data = this.getFrequencyData();
@@ -34,6 +35,6 @@ Object.assign( AudioAnalyser.prototype, {
3435

3536
}
3637

37-
} );
38+
}
3839

3940
export { AudioAnalyser };

0 commit comments

Comments
 (0)