comparison src/CQSpectrogram.cpp @ 156:b34df30fd7e4

Defensive initialisation
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 04 Aug 2014 09:21:48 +0100
parents 1060a19e2334
children
comparison
equal deleted inserted replaced
155:72dd182be968 156:b34df30fd7e4
35 #include <stdexcept> 35 #include <stdexcept>
36 36
37 using std::cerr; 37 using std::cerr;
38 using std::endl; 38 using std::endl;
39 39
40 //#define DEBUG_CQSPECTROGRAM 1
41
40 CQSpectrogram::CQSpectrogram(CQParameters params, 42 CQSpectrogram::CQSpectrogram(CQParameters params,
41 Interpolation interpolation) : 43 Interpolation interpolation) :
42 m_cq(params), 44 m_cq(params),
43 m_interpolation(interpolation) 45 m_interpolation(interpolation)
44 { 46 {
69 RealBlock spec; 71 RealBlock spec;
70 for (int i = 0; i < width; ++i) { 72 for (int i = 0; i < width; ++i) {
71 int height = cq[i].size(); 73 int height = cq[i].size();
72 RealColumn col(height, 0); 74 RealColumn col(height, 0);
73 for (int j = 0; j < height; ++j) { 75 for (int j = 0; j < height; ++j) {
74 76 #ifdef DEBUG_CQSPECTROGRAM
75 if (isnan(cq[i][j].real())) { 77 if (isnan(cq[i][j].real())) {
76 cerr << "WARNING: NaN in real at (" << i << "," << j << ")" << endl; 78 cerr << "WARNING: NaN in real at (" << i << "," << j << ")" << endl;
77 } 79 }
78 if (isnan(cq[i][j].imag())) { 80 if (isnan(cq[i][j].imag())) {
79 cerr << "WARNING: NaN in imag at (" << i << "," << j << ")" << endl; 81 cerr << "WARNING: NaN in imag at (" << i << "," << j << ")" << endl;
80 } 82 }
81 83 #endif
82 col[j] = abs(cq[i][j]); 84 col[j] = abs(cq[i][j]);
83 } 85 }
84 spec.push_back(col); 86 spec.push_back(col);
85 } 87 }
86 88