Mercurial > hg > silvet
diff src/EM.cpp @ 112:2169e7a448c5 bqvec-openmp
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 07 May 2014 09:01:32 +0100 |
parents | 9b299b087dd4 e282930cfca7 |
children | c4eae816bdb3 |
line wrap: on
line diff
--- a/src/EM.cpp Wed May 07 08:55:44 2014 +0100 +++ b/src/EM.cpp Wed May 07 09:01:32 2014 +0100 @@ -33,9 +33,10 @@ static double epsilon = 1e-16; -EM::EM() : +EM::EM(bool useShifts) : + m_useShifts(useShifts), m_noteCount(SILVET_TEMPLATE_NOTE_COUNT), - m_shiftCount(SILVET_TEMPLATE_MAX_SHIFT * 2 + 1), + m_shiftCount(useShifts ? SILVET_TEMPLATE_MAX_SHIFT * 2 + 1 : 1), m_binCount(SILVET_TEMPLATE_HEIGHT), m_sourceCount(SILVET_TEMPLATE_COUNT), m_pitchSparsity(1.1), @@ -53,7 +54,11 @@ m_updateShifts = allocate_channels<double>(m_shiftCount, m_noteCount); for (int f = 0; f < m_shiftCount; ++f) { for (int n = 0; n < m_noteCount; ++n) { - m_shifts[f][n] = drand48(); + if (m_useShifts) { + m_shifts[f][n] = drand48(); + } else { + m_shifts[f][n] = 1.0; + } } } @@ -135,7 +140,12 @@ const double * EM::templateFor(int instrument, int note, int shift) { - return silvet_templates[instrument].data[note] + shift; + if (m_useShifts) { + return silvet_templates[instrument].data[note] + shift; + } else { + return silvet_templates[instrument].data[note] + + SILVET_TEMPLATE_MAX_SHIFT; + } } void @@ -227,11 +237,14 @@ } normaliseColumn(m_updatePitches, m_noteCount); - normaliseGrid(m_updateShifts, m_shiftCount, m_noteCount); + std::swap(m_pitches, m_updatePitches); + + if (m_useShifts) { + normaliseGrid(m_updateShifts, m_shiftCount, m_noteCount); + std::swap(m_shifts, m_updateShifts); + } + normaliseGrid(m_updateSources, m_sourceCount, m_noteCount); - - std::swap(m_pitches, m_updatePitches); - std::swap(m_shifts, m_updateShifts); std::swap(m_sources, m_updateSources); }