diff options
author | Robin Gareus <robin@gareus.org> | 2016-12-28 22:18:41 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-12-28 22:19:37 +0100 |
commit | e1846c79a9292d4e58527aa1d2a33119ea966902 (patch) | |
tree | 6eccf1c683ab3596902b2ffe1b4c227173230acf /libs/ardour/audioregion.cc | |
parent | 910e369140aebd0288bbb2f9e5a643549ab4b93f (diff) |
Fix AudioRegion RMS calc for multi-channel
Diffstat (limited to 'libs/ardour/audioregion.cc')
-rw-r--r-- | libs/ardour/audioregion.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 873d4119d4..bf4c5c6910 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -1454,13 +1454,12 @@ AudioRegion::rms (Progress* p) const framecnt_t total = 0; - if (n_chan == 0) { + if (n_chan == 0 || fend == fpos) { return 0; } while (fpos < fend) { framecnt_t const to_read = min (fend - fpos, blocksize); - total += to_read; for (uint32_t c = 0; c < n_chan; ++c) { if (read_raw_internal (buf, fpos, to_read, c) != to_read) { return 0; @@ -1468,12 +1467,13 @@ AudioRegion::rms (Progress* p) const for (framepos_t i = 0; i < to_read; ++i) { rms += buf[i] * buf[i]; } - fpos += to_read; - if (p) { - p->set_progress (float (fpos - _start) / _length); - if (p->cancelled ()) { - return -1; - } + } + total += to_read; + fpos += to_read; + if (p) { + p->set_progress (float (fpos - _start) / _length); + if (p->cancelled ()) { + return -1; } } } |