diff options
author | Jonas Suhr Christensen <jsc@umbraculum.org> | 2014-03-19 21:11:31 +0100 |
---|---|---|
committer | Jonas Suhr Christensen <jsc@umbraculum.org> | 2014-03-19 21:11:31 +0100 |
commit | aa656f19d015febb1174c0c91cb1711657280c70 (patch) | |
tree | bedcde25df2bd4e9f1286047d2e47071bda0d94a /src/powerlist.cc | |
parent | d6f325454d47546d56525cf64c528f35f8dec430 (diff) |
Using power defined in xml if any.
Diffstat (limited to 'src/powerlist.cc')
-rw-r--r-- | src/powerlist.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/powerlist.cc b/src/powerlist.cc index 4f02892..cf843a3 100644 --- a/src/powerlist.cc +++ b/src/powerlist.cc @@ -168,16 +168,22 @@ void PowerList::finalise() master->load(); float power = 0; - size_t s = 0; - for(; s < SIZE && s < master->size; s++) { - power += master->data[s] * master->data[s]; - } + if(sample->power == -1) { // Power not defined. Calculate it! + DEBUG(powerlist, "Calculating power\n"); + size_t s = 0; + for(; s < SIZE && s < master->size; s++) { + power += master->data[s] * master->data[s]; + } - power = sqrt(power); + power = sqrt(power); - if(power > power_max) power_max = power; + if(power > power_max) power_max = power; - item.power = power; + item.power = power; + } else { // Power defined in xml + DEBUG(powerlist, "Using power from xml\n"); + power = sample->power; + } DEBUG(rand, " - power: %f\n", power); |