mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 11:46:25 +01:00
Fix AudioRegion RMS calc for multi-channel
This commit is contained in:
parent
910e369140
commit
e1846c79a9
1 changed files with 8 additions and 8 deletions
|
|
@ -1454,13 +1454,12 @@ AudioRegion::rms (Progress* p) const
|
||||||
|
|
||||||
framecnt_t total = 0;
|
framecnt_t total = 0;
|
||||||
|
|
||||||
if (n_chan == 0) {
|
if (n_chan == 0 || fend == fpos) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fpos < fend) {
|
while (fpos < fend) {
|
||||||
framecnt_t const to_read = min (fend - fpos, blocksize);
|
framecnt_t const to_read = min (fend - fpos, blocksize);
|
||||||
total += to_read;
|
|
||||||
for (uint32_t c = 0; c < n_chan; ++c) {
|
for (uint32_t c = 0; c < n_chan; ++c) {
|
||||||
if (read_raw_internal (buf, fpos, to_read, c) != to_read) {
|
if (read_raw_internal (buf, fpos, to_read, c) != to_read) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1468,12 +1467,13 @@ AudioRegion::rms (Progress* p) const
|
||||||
for (framepos_t i = 0; i < to_read; ++i) {
|
for (framepos_t i = 0; i < to_read; ++i) {
|
||||||
rms += buf[i] * buf[i];
|
rms += buf[i] * buf[i];
|
||||||
}
|
}
|
||||||
fpos += to_read;
|
}
|
||||||
if (p) {
|
total += to_read;
|
||||||
p->set_progress (float (fpos - _start) / _length);
|
fpos += to_read;
|
||||||
if (p->cancelled ()) {
|
if (p) {
|
||||||
return -1;
|
p->set_progress (float (fpos - _start) / _length);
|
||||||
}
|
if (p->cancelled ()) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue