Mercurial > hg > pyin
comparison MonoNoteHMM.cpp @ 94:2687ba2cafae
some cleaning up
author | matthiasm |
---|---|
date | Wed, 07 Jan 2015 17:05:07 +0000 |
parents | 854d9403c5be |
children | 080fe18f5ebf |
comparison
equal
deleted
inserted
replaced
93:b24668a40770 | 94:2687ba2cafae |
---|---|
125 size_t index = iPitch * par.nSPP; | 125 size_t index = iPitch * par.nSPP; |
126 double mu = par.minPitch + iPitch * 1.0/par.nPPS; | 126 double mu = par.minPitch + iPitch * 1.0/par.nPPS; |
127 pitchDistr[index] = boost::math::normal(mu, par.sigmaYinPitchAttack); | 127 pitchDistr[index] = boost::math::normal(mu, par.sigmaYinPitchAttack); |
128 pitchDistr[index+1] = boost::math::normal(mu, par.sigmaYinPitchStable); | 128 pitchDistr[index+1] = boost::math::normal(mu, par.sigmaYinPitchStable); |
129 pitchDistr[index+2] = boost::math::normal(mu, 1.0); // dummy | 129 pitchDistr[index+2] = boost::math::normal(mu, 1.0); // dummy |
130 pitchDistr[index+3] = boost::math::normal(mu, par.sigmaYinPitchInter); | |
131 } | 130 } |
132 | 131 |
133 boost::math::normal noteDistanceDistr(0, par.sigma2Note); | 132 boost::math::normal noteDistanceDistr(0, par.sigma2Note); |
134 | 133 |
135 for (size_t iPitch = 0; iPitch < (par.nS * par.nPPS); ++iPitch) | 134 for (size_t iPitch = 0; iPitch < (par.nS * par.nPPS); ++iPitch) |
153 | 152 |
154 from.push_back(index+1); | 153 from.push_back(index+1); |
155 to.push_back(index+2); // to silent | 154 to.push_back(index+2); // to silent |
156 transProb.push_back(par.pStable2Silent); | 155 transProb.push_back(par.pStable2Silent); |
157 | 156 |
158 // from.push_back(index+1); | |
159 // to.push_back(index+3); // to inter-note | |
160 // transProb.push_back(1-par.pStableSelftrans-par.pStable2Silent); | |
161 | |
162 // the "easy" transitions from silent state | 157 // the "easy" transitions from silent state |
163 from.push_back(index+2); | 158 from.push_back(index+2); |
164 to.push_back(index+2); | 159 to.push_back(index+2); |
165 transProb.push_back(par.pSilentSelftrans); | 160 transProb.push_back(par.pSilentSelftrans); |
166 | 161 |
167 // // the "easy" inter state transition | |
168 // from.push_back(index+3); | |
169 // to.push_back(index+3); | |
170 // transProb.push_back(par.pInterSelftrans); | |
171 | 162 |
172 // the more complicated transitions from the silent and inter state | 163 // the more complicated transitions from the silent |
173 double probSumSilent = 0; | 164 double probSumSilent = 0; |
174 // double probSumInter = 0; | 165 |
175 // vector<double> tempTransProbInter; | |
176 vector<double> tempTransProbSilent; | 166 vector<double> tempTransProbSilent; |
177 for (size_t jPitch = 0; jPitch < (par.nS * par.nPPS); ++jPitch) | 167 for (size_t jPitch = 0; jPitch < (par.nS * par.nPPS); ++jPitch) |
178 { | 168 { |
179 int fromPitch = iPitch; | 169 int fromPitch = iPitch; |
180 int toPitch = jPitch; | 170 int toPitch = jPitch; |
188 { | 178 { |
189 size_t toIndex = jPitch * par.nSPP; // note attack index | 179 size_t toIndex = jPitch * par.nSPP; // note attack index |
190 | 180 |
191 double tempWeightSilent = boost::math::pdf(noteDistanceDistr, | 181 double tempWeightSilent = boost::math::pdf(noteDistanceDistr, |
192 semitoneDistance); | 182 semitoneDistance); |
193 // double tempWeightInter = semitoneDistance == 0 ? | |
194 // 0 : tempWeightSilent; | |
195 probSumSilent += tempWeightSilent; | 183 probSumSilent += tempWeightSilent; |
196 // probSumInter += tempWeightInter; | |
197 | 184 |
198 tempTransProbSilent.push_back(tempWeightSilent); | 185 tempTransProbSilent.push_back(tempWeightSilent); |
199 // tempTransProbInter.push_back(tempWeightInter); | |
200 | 186 |
201 from.push_back(index+2); | 187 from.push_back(index+2); |
202 to.push_back(toIndex); | 188 to.push_back(toIndex); |
203 // from.push_back(index+3); | |
204 // to.push_back(toIndex); | |
205 } | 189 } |
206 } | 190 } |
207 for (size_t i = 0; i < tempTransProbSilent.size(); ++i) | 191 for (size_t i = 0; i < tempTransProbSilent.size(); ++i) |
208 { | 192 { |
209 transProb.push_back((1-par.pSilentSelftrans) * tempTransProbSilent[i]/probSumSilent); | 193 transProb.push_back((1-par.pSilentSelftrans) * tempTransProbSilent[i]/probSumSilent); |
210 // transProb.push_back((1-par.pInterSelftrans) * tempTransProbInter[i]/probSumInter); | |
211 } | 194 } |
212 } | 195 } |
213 } | 196 } |
214 | 197 |
215 double | 198 double |