Failed to execute 'createBuffer' on 'BaseAudioContext': The number of frames provided (0) is less than or equal to the minimum bound (0)."
My project attempts to create an audiobuffer for a Float32Array stream chunk.
initialization of audiocontext
constructor(loading: LoadingService) {
...
this.audiocontext = new audiocontext()
...
}
creation of audio buffer
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()
}
It fails at the source line where the newbuffer
variable is defined. I dont understand how I can "provide frames" without creating the buffer first.
All solution thoughts would be appreciated.
@Kaiido It's embarrassing but that was the right answer! I need to remember to always check my assumptions.