Skip to content

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

@SDwarfs

Description

@SDwarfs

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions