Mercurial > hg > silvet
comparison src/EM.cpp @ 42:c0c4a945577a
Sparsity parameters
author | Chris Cannam |
---|---|
date | Sat, 05 Apr 2014 18:10:33 +0100 |
parents | b49597c93132 |
children | e92376d450b0 9b17bbd16a5f |
comparison
equal
deleted
inserted
replaced
41:b49597c93132 | 42:c0c4a945577a |
---|---|
16 #include "EM.h" | 16 #include "EM.h" |
17 | 17 |
18 #include "data/include/templates.h" | 18 #include "data/include/templates.h" |
19 | 19 |
20 #include <cstdlib> | 20 #include <cstdlib> |
21 #include <cmath> | |
21 | 22 |
22 #include <iostream> | 23 #include <iostream> |
23 | 24 |
24 #include <vector> | 25 #include <vector> |
25 | 26 |
30 static double epsilon = 1e-16; | 31 static double epsilon = 1e-16; |
31 | 32 |
32 EM::EM() : | 33 EM::EM() : |
33 m_notes(SILVET_TEMPLATE_NOTE_COUNT), | 34 m_notes(SILVET_TEMPLATE_NOTE_COUNT), |
34 m_bins(SILVET_TEMPLATE_HEIGHT), | 35 m_bins(SILVET_TEMPLATE_HEIGHT), |
35 m_instruments(SILVET_TEMPLATE_COUNT) | 36 m_instruments(SILVET_TEMPLATE_COUNT), |
37 m_pitchSparsity(1.1), | |
38 m_sourceSparsity(1.3) | |
36 { | 39 { |
37 m_lowest = 0; | 40 m_lowest = 0; |
38 m_highest = m_notes - 1; | 41 m_highest = m_notes - 1; |
39 | 42 |
40 for (int i = 0; i < m_instruments; ++i) { | 43 for (int i = 0; i < m_instruments; ++i) { |
136 for (int j = 0; j < m_bins; ++j) { | 139 for (int j = 0; j < m_bins; ++j) { |
137 newPitches[n] += w[j] * m_q[j] * pitch * source; | 140 newPitches[n] += w[j] * m_q[j] * pitch * source; |
138 } | 141 } |
139 } | 142 } |
140 } | 143 } |
144 if (m_pitchSparsity != 1.0) { | |
145 newPitches[n] = pow(newPitches[n], m_pitchSparsity); | |
146 } | |
141 } | 147 } |
142 normalise(newPitches); | 148 normalise(newPitches); |
143 | 149 |
144 Grid newSources = m_sources; | 150 Grid newSources = m_sources; |
145 | 151 |
151 double pitch = m_pitches[n]; | 157 double pitch = m_pitches[n]; |
152 double source = m_sources[i][n]; | 158 double source = m_sources[i][n]; |
153 for (int j = 0; j < m_bins; ++j) { | 159 for (int j = 0; j < m_bins; ++j) { |
154 newSources[i][n] += w[j] * m_q[j] * pitch * source; | 160 newSources[i][n] += w[j] * m_q[j] * pitch * source; |
155 } | 161 } |
162 } | |
163 if (m_sourceSparsity != 1.0) { | |
164 newSources[i][n] = pow(newSources[i][n], m_sourceSparsity); | |
156 } | 165 } |
157 } | 166 } |
158 normalise(newSources[i]); | 167 normalise(newSources[i]); |
159 } | 168 } |
160 | 169 |