Skip to content

Commit 435b572

Browse files
committed
perf: change arrayBuffer trigger position
1 parent 26134d5 commit 435b572

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/modules/Audio.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class WebAudio {
1212
protected audioBuffer!: AudioBuffer
1313
protected audioBufferSourceNode!: AudioBufferSourceNode
1414
private filterData!: number[][]
15-
private response!: Response
15+
private arrayBuffer!: ArrayBuffer
1616

1717
constructor(props: IllestWaveformProps) {
1818
this.props = props
@@ -36,15 +36,15 @@ export default class WebAudio {
3636

3737
public async fetchAudioFile(): Promise<void> {
3838
try {
39-
this.response = await fetch(this.props.url)
39+
const response = await fetch(this.props.url)
40+
this.arrayBuffer = await response.arrayBuffer()
4041
} catch (error) {
4142
console.error(error)
4243
}
4344
}
4445

4546
private async createAudioBuffer(): Promise<void> {
46-
const arrayBuffer: ArrayBuffer = await this.response.arrayBuffer()
47-
this.audioBuffer = await this.audioCtx.decodeAudioData(arrayBuffer)
47+
this.audioBuffer = await this.audioCtx.decodeAudioData(this.arrayBuffer)
4848
}
4949

5050
private createFilterData(): void {

0 commit comments

Comments
 (0)