无法在“ BaseAudioContext”上执行“ createBuffer”: 提供的帧数(0)小于或等于最小边界(0)。“
我的项目尝试为Float32Array流块创建音频缓冲区。
音频上下文的初始化
constructor(loading: LoadingService) {
...
this.audiocontext = new audiocontext()
...
}
创建音频缓冲区
private onmusicdownloaded = (response: streamresponse) => {
if(response.totalchunks !== 0 &&
isnullorundefined(this.buffers)) {
this.buffers = new Array<AudioBuffer>(response.totalchunks) //lets me make correct playback decisions
}
console.log('stream chunk received')
this.currentbufferdownloaded++
let rawbuffer = new Float32Array(response.chunk)
let newbuffer = this.audiocontext.createBuffer(1, rawbuffer.length, 44100)
newbuffer.getChannelData(0)
.set(rawbuffer)
this.buffers[this.currentbufferdownloaded] = newbuffer
this.currentbufferdownloaded++
if(this.musicisreadytoplay() === false) {
return
}
this.playrandomdeserttrack()
}
它在定义了newbuffer
变量的源代码行中失败。我不明白如何在不先创建缓冲区的情况下“提供帧”。
所有解决方案的想法将不胜感激。
答案 0 :(得分:1)
@Kaiido令人尴尬,但这是正确的答案!我需要记住要始终检查自己的假设。
https://www.jetbrains.com/help/webstorm/viewing-method-parameter-information.html