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

A small clamping inaccuracy in the oto Speaker writer #88

Open
ajzaff opened this issue Jun 12, 2020 · 1 comment
Open

A small clamping inaccuracy in the oto Speaker writer #88

ajzaff opened this issue Jun 12, 2020 · 1 comment

Comments

@ajzaff
Copy link

ajzaff commented Jun 12, 2020

valInt16 := int16(val * (1<<15 - 1))

Currently this returns the wrong values for an input of -1.

I believe this should fix it:

valInt16 = int16((-1<<15)+(val+1)/2*(1<<16-1))

https://play.golang.org/p/E-8wkFoIHQ3

@ajzaff ajzaff changed the title A small bug in the Speaker An overflow in the oto Speaker writer Jun 12, 2020
@ajzaff ajzaff changed the title An overflow in the oto Speaker writer A small clamping inaccuracy in the oto Speaker writer Jun 12, 2020
@MarkKremer
Copy link
Contributor

Fun fact, in the latest release of Oto the samples get converted back to floats. Maybe a better option to just pass raw float bytes to Oto and skip the conversion altogether.

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

2 participants