13
0

Fix AudioRegion RMS calc for multi-channel

This commit is contained in:
Robin Gareus 2016-12-28 22:18:41 +01:00
parent 910e369140
commit e1846c79a9

View File

@ -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;
}
}
}