Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerical truncation bug in function addFloatSamplesToInputBuffer #48

Open
ffiirree opened this issue Feb 17, 2024 · 0 comments
Open

Numerical truncation bug in function addFloatSamplesToInputBuffer #48

ffiirree opened this issue Feb 17, 2024 · 0 comments

Comments

@ffiirree
Copy link

ffiirree commented Feb 17, 2024

Hi, I found that it could be a numerical truncation bug in

sonic/sonic.c

Line 519 in 8694c59

*buffer++ = (*samples++) * 32767.0f;

*samples could be out of range [-1.0, 1.0].

It should be guaranteed that the value of (*samples++) * 32767.0f is in the range [-32767, 32767], otherwise noise will be introduced. Just like here:

sonic/sonic.c

Lines 271 to 277 in 8694c59

value = (*samples * fixedPointVolume) >> 8;
if (value > 32767) {
value = 32767;
} else if (value < -32767) {
value = -32767;
}
*samples++ = value;

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant