Fixing a bug that resulted with broken pitch range on non MSVC systems. (#215)

This commit is contained in:
Waldemar Pawlaszek 2022-02-23 22:48:06 +01:00 committed by GitHub
parent 29cae1a3f8
commit 8d1da90d78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,7 +52,7 @@ static int bsr(uint16_t v) {
static int bsr(uint16_t v) static int bsr(uint16_t v)
{ {
if (v) { if (v) {
return 16 - __builtin_clz(v); return 32 - __builtin_clz(v);
} }
else{ else{
return -1; return -1;
@ -64,7 +64,7 @@ static int bsr(uint16_t v)
static int bsr(uint16_t v) static int bsr(uint16_t v)
{ {
uint16_t mask = 0x8000; uint16_t mask = 0x8000;
for (int i = 31; i >= 0; --i) { for (int i = 15; i >= 0; --i) {
if (v&mask) if (v&mask)
return (int)i; return (int)i;
mask>>=1; mask>>=1;