Fix for endIndex == 0 breaking audio

The audio seems to break whenever endIndex goes to O, making "second" variable a 
``bash
Float32Array [buffer: SharedArrayBuffer(17640), byteLength: 0, byteOffset: 0, length: 0, Symbol(Symbol.toStringTag): 'Float32Array']
buffer:SharedArrayBuffer(17640)
byteLength:0
byteOffset:0
length: 0
Symbol(Symbol.toStringTag): "Float32Array"
[[Prototype]]:TypedArray
``
This commit is contained in:
Wanjohi 2023-05-15 23:50:17 +03:00 committed by GitHub
parent 43af19ba94
commit 14bb3e80b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -50,7 +50,9 @@ export class Ring {
planeIndex: i,
frameCount: count,
})
} else {
//audio seems to be breaking whenever endIndex is 0
//this works, without "chopiness"
} else if (startIndex >= endIndex && endIndex != 0) {
const first = channel.subarray(startIndex)
const second = channel.subarray(0, endIndex)
@ -59,9 +61,7 @@ export class Ring {
frameCount: first.length,
})
//For some reason this breaks audio... and this is my temporary fix
//console.log("frame offset", first.length , "frame count", second.length) to test
if (first.length < second.length) {
frame.copyTo(second, {
planeIndex: i,
frameOffset: first.length,
@ -69,7 +69,6 @@ export class Ring {
})
}
}
}
Atomics.store(this.state, STATE.WRITE_INDEX, writeIndexNew)