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!
In line 143 the
samplenumfor 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 correctsamplenuminstead.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!