Mercurial > hg > silvet
changeset 112:2169e7a448c5 bqvec-openmp
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 07 May 2014 09:01:32 +0100 |
parents | 9b299b087dd4 (current diff) e282930cfca7 (diff) |
children | c4eae816bdb3 |
files | src/EM.cpp src/EM.h src/Silvet.cpp testdata/timing/results.txt |
diffstat | 6 files changed, 60 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsubstate Wed May 07 08:55:44 2014 +0100 +++ b/.hgsubstate Wed May 07 09:01:32 2014 +0100 @@ -1,1 +1,1 @@ -08f90c46ac6ba30d9e96517a20dba5be70b66d56 constant-q-cpp +7d97986563a0b3104a5c3f88190350ae55528738 constant-q-cpp
--- 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); }
--- a/src/EM.h Wed May 07 08:55:44 2014 +0100 +++ b/src/EM.h Wed May 07 09:01:32 2014 +0100 @@ -21,7 +21,7 @@ class EM { public: - EM(); + EM(bool useShifts); ~EM(); int getBinCount() const { return m_binCount; } // size of input column @@ -49,6 +49,8 @@ double **m_updateShifts; double **m_updateSources; + bool m_useShifts; + double *m_estimate; double *m_q;
--- a/src/Silvet.cpp Wed May 07 08:55:44 2014 +0100 +++ b/src/Silvet.cpp Wed May 07 09:01:32 2014 +0100 @@ -40,7 +40,8 @@ Silvet::Silvet(float inputSampleRate) : Plugin(inputSampleRate), m_resampler(0), - m_cq(0) + m_cq(0), + m_hqMode(false) { } @@ -129,18 +130,39 @@ Silvet::getParameterDescriptors() const { ParameterList list; + + ParameterDescriptor desc; + desc.identifier = "mode"; + desc.name = "Processing mode"; + desc.unit = ""; + desc.description = "Determines the tradeoff of processing speed against transcription quality"; + desc.minValue = 0; + desc.maxValue = 1; + desc.defaultValue = 0; + desc.isQuantized = true; + desc.quantizeStep = 1; + desc.valueNames.push_back("Draft (faster)"); + desc.valueNames.push_back("Intensive (higher quality)"); + list.push_back(desc); + return list; } float Silvet::getParameter(string identifier) const { + if (identifier == "mode") { + return m_hqMode ? 1.f : 0.f; + } return 0; } void Silvet::setParameter(string identifier, float value) { + if (identifier == "mode") { + m_hqMode = (value > 0.5); + } } Silvet::ProgramList @@ -411,7 +433,7 @@ if (sum < 1e-5) continue; - EM em; + EM em(m_hqMode); for (int j = 0; j < iterations; ++j) { em.iterate(filtered[i + k].data()); }
--- a/src/Silvet.h Wed May 07 08:55:44 2014 +0100 +++ b/src/Silvet.h Wed May 07 09:01:32 2014 +0100 @@ -73,6 +73,8 @@ Resampler *m_resampler; CQInterpolated *m_cq; + bool m_hqMode; + typedef vector<vector<double> > Grid; vector<MedianFilter<double> *> m_postFilter;
--- a/testdata/timing/results.txt Wed May 07 08:55:44 2014 +0100 +++ b/testdata/timing/results.txt Wed May 07 09:01:32 2014 +0100 @@ -142,6 +142,15 @@ user 1m39.000s sys 0m0.183s +commit:840c0d703bbb, as commit:a6e136aaa202 but using single-precision +floats for all EM code (and templates). This is probably not wise +without separately testing the quality of the results but it's +interesting to compare + +real 1m29.003s +user 1m28.697s +sys 0m0.197s + BQVEC: