-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The code for unsigned to signed integer conversion is incorrect.
Paste this into console, and the result is wrong.
function scale(value, bitDepth)
{
var range = 1 << bitDepth - 1;
if (value >= range) {
value |= ~(range - 1);
}
return value;
}
[0, 1, 2, 3].forEach(function(n) {console.log(n + ", " + scale(n, 2))})
Output:
0, 0
1, 1
2, -2
3, -1
Moreover, according to stack overflow, greater than 8 bits per sample is already signed, so there is no need to do this conversion.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels