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

wrong calculations of loop_end (assuming 4 bytes per sample) #18

Open
SDwarfs opened this issue Apr 6, 2023 · 0 comments
Open

wrong calculations of loop_end (assuming 4 bytes per sample) #18

SDwarfs opened this issue Apr 6, 2023 · 0 comments

Comments

@SDwarfs
Copy link

SDwarfs commented Apr 6, 2023

In line 143 the samplenum for setting loop_end is calculated wrong. It assumes 4 bytes per sample, which isn't always correct and hence causes the loop to start earlier in some cases (e.g. 16 bit per sample / mono). As the bits_per_sample is calculated above it should be used to calculate the correct samplenum instead.

OLD: var samplenum = newstream.data.size() / 4 (line 143)
NEW: var samplenum = newstream.data.size() / (bits_per_sample / 8)

Note, that the bits_per_sample is initialized with 0. Hence this might result in a division by 0. Hence, I suggest something like assert(bits_per_sample != 0) as done above in the code... or do some other error handling. 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