Mercurial > hg > svcore
changeset 1152:d73b4bac2dc4 3.0-integration
Fix one-block rounding error when zoomed a long way out, visible as an offset toward the end of very long audio files
author | Chris Cannam |
---|---|
date | Fri, 22 Jan 2016 12:46:19 +0000 |
parents | def42cbba8bc |
children | ece369c5bb68 |
files | data/model/ReadOnlyWaveFileModel.cpp |
diffstat | 1 files changed, 6 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/data/model/ReadOnlyWaveFileModel.cpp Fri Jan 22 09:52:30 2016 +0000 +++ b/data/model/ReadOnlyWaveFileModel.cpp Fri Jan 22 12:46:19 2016 +0000 @@ -403,14 +403,12 @@ blockSize = roundedBlockSize; sv_frame_t cacheBlock, div; - - if (cacheType == 0) { - cacheBlock = (1 << m_zoomConstraint.getMinCachePower()); - div = (1 << power) / cacheBlock; - } else { - cacheBlock = sv_frame_t((1 << m_zoomConstraint.getMinCachePower()) * sqrt(2.) + 0.01); - div = sv_frame_t(((1 << power) * sqrt(2.) + 0.01) / double(cacheBlock)); + + cacheBlock = (sv_frame_t(1) << m_zoomConstraint.getMinCachePower()); + if (cacheType == 1) { + cacheBlock = sv_frame_t(double(cacheBlock) * sqrt(2.) + 0.01); } + div = blockSize / cacheBlock; sv_frame_t startIndex = start / cacheBlock; sv_frame_t endIndex = (start + count) / cacheBlock; @@ -425,7 +423,7 @@ for (i = 0; i <= endIndex - startIndex; ) { sv_frame_t index = (i + startIndex) * channels + channel; - if (index >= (sv_frame_t)cache.size()) break; + if (!in_range_for(cache, index)) break; const Range &range = cache[index]; if (range.max() > max || got == 0) max = range.max();