comparison src/LiveInstruments.cpp @ 346:5acce45e2ec6

Avoid NaN in empty notes in template matrix
author Chris Cannam
date Wed, 12 Aug 2015 16:01:58 +0100
parents 4cf4313d7e30
children
comparison
equal deleted inserted replaced
345:506f57984407 346:5acce45e2ec6
75 // re-normalise 75 // re-normalise
76 for (auto &t: templates) { 76 for (auto &t: templates) {
77 for (auto &d: t.data) { 77 for (auto &d: t.data) {
78 float sum = 0.f; 78 float sum = 0.f;
79 for (auto v: d) sum += v; 79 for (auto v: d) sum += v;
80 for (auto &v: d) v /= sum; 80 if (sum > 0.f) {
81 for (auto &v: d) v /= sum;
82 }
81 } 83 }
82 } 84 }
83 85
84 InstrumentPack live(original.lowestNote, 86 InstrumentPack live(original.lowestNote,
85 original.highestNote, 87 original.highestNote,