comparison src/EM.cpp @ 88:97b77e7cb94c timing

Store templates as doubles instead of floats
author Chris Cannam
date Tue, 06 May 2014 12:49:49 +0100
parents 6075e92d63ab
children a6e136aaa202
comparison
equal deleted inserted replaced
87:a44c52983ec2 88:97b77e7cb94c
120 normaliseColumn(column); 120 normaliseColumn(column);
121 expectation(column); 121 expectation(column);
122 maximisation(column); 122 maximisation(column);
123 } 123 }
124 124
125 const float * 125 const double *
126 EM::templateFor(int instrument, int note, int shift) 126 EM::templateFor(int instrument, int note, int shift)
127 { 127 {
128 return silvet_templates[instrument].data[note] + shift; 128 return silvet_templates[instrument].data[note] + shift;
129 } 129 }
130 130
140 for (int i = 0; i < m_instrumentCount; ++i) { 140 for (int i = 0; i < m_instrumentCount; ++i) {
141 for (int n = 0; n < m_noteCount; ++n) { 141 for (int n = 0; n < m_noteCount; ++n) {
142 const double pitch = m_pitches[n]; 142 const double pitch = m_pitches[n];
143 const double source = m_sources[i][n]; 143 const double source = m_sources[i][n];
144 for (int f = 0; f < m_shiftCount; ++f) { 144 for (int f = 0; f < m_shiftCount; ++f) {
145 const float *w = templateFor(i, n, f); 145 const double *w = templateFor(i, n, f);
146 const double shift = m_shifts[f][n]; 146 const double shift = m_shifts[f][n];
147 const double factor = pitch * source * shift; 147 const double factor = pitch * source * shift;
148 for (int j = 0; j < m_binCount; ++j) { 148 for (int j = 0; j < m_binCount; ++j) {
149 m_estimate[j] += w[j] * factor; 149 m_estimate[j] += w[j] * factor;
150 } 150 }
177 for (int i = 0; i < m_instrumentCount; ++i) { 177 for (int i = 0; i < m_instrumentCount; ++i) {
178 178
179 const double source = m_sources[i][n]; 179 const double source = m_sources[i][n];
180 newSources[i][n] = epsilon; 180 newSources[i][n] = epsilon;
181 181
182 const float *w = templateFor(i, n, f); 182 const double *w = templateFor(i, n, f);
183 const double factor = pitch * source * shift; 183 const double factor = pitch * source * shift;
184 184
185 if (n >= m_lowestPitch && n <= m_highestPitch) { 185 if (n >= m_lowestPitch && n <= m_highestPitch) {
186 186
187 for (int j = 0; j < m_binCount; ++j) { 187 for (int j = 0; j < m_binCount; ++j) {