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

Why divide by 32768? #8

Closed
aunyks opened this issue Nov 17, 2020 · 1 comment
Closed

Why divide by 32768? #8

aunyks opened this issue Nov 17, 2020 · 1 comment

Comments

@aunyks
Copy link

aunyks commented Nov 17, 2020

On lines 108 and 109 in main.rs, why do we divide the f32s by 32768? What does this action achieve?

When reading these lines, it appeared to me that the bitwise operations successfully converted the u8 values into f32 values, but I don't quite understand why they're divided by a number afterward.

let i: f32 = ((b[1] as i16) << 8 | b[0] as i16) as f32 / 32768.;
let q: f32 = ((b[3] as i16) << 8 | b[2] as i16) as f32 / 32768.;
@andresv
Copy link
Member

andresv commented Nov 17, 2020

i and q are normalized to -1.0..1.0

@andresv andresv closed this as completed Nov 17, 2020
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