Mercurial > hg > constant-q-cpp
comparison vamp/CQVamp.cpp @ 90:bfc7cf71f2ef
Rearrange classes so the basic ConstantQ produces a complex output, and CQSpectrogram (formerly CQInterpolated) is required if you want a real output
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 09 May 2014 10:05:16 +0100 |
parents | f4fb0ac6120a |
children | fa1709ed4a3c |
comparison
equal
deleted
inserted
replaced
89:25947630486b | 90:bfc7cf71f2ef |
---|---|
45 Vamp::Plugin(inputSampleRate), | 45 Vamp::Plugin(inputSampleRate), |
46 m_minMIDIPitch(36), | 46 m_minMIDIPitch(36), |
47 m_maxMIDIPitch(84), | 47 m_maxMIDIPitch(84), |
48 m_tuningFrequency(440), | 48 m_tuningFrequency(440), |
49 m_bpo(24), | 49 m_bpo(24), |
50 m_interpolation(CQInterpolated::Linear), | 50 m_interpolation(CQSpectrogram::InterpolateLinear), |
51 m_cq(0), | 51 m_cq(0), |
52 m_maxFrequency(inputSampleRate/2), | 52 m_maxFrequency(inputSampleRate/2), |
53 m_minFrequency(46), | 53 m_minFrequency(46), |
54 m_haveStartTime(false), | 54 m_haveStartTime(false), |
55 m_columnCount(0) | 55 m_columnCount(0) |
153 desc.minValue = 0; | 153 desc.minValue = 0; |
154 desc.maxValue = 2; | 154 desc.maxValue = 2; |
155 desc.defaultValue = 2; | 155 desc.defaultValue = 2; |
156 desc.isQuantized = true; | 156 desc.isQuantized = true; |
157 desc.quantizeStep = 1; | 157 desc.quantizeStep = 1; |
158 desc.valueNames.push_back("None, leave empty"); | 158 desc.valueNames.push_back("None, leave as zero"); |
159 desc.valueNames.push_back("None, repeat prior value"); | 159 desc.valueNames.push_back("None, repeat prior value"); |
160 desc.valueNames.push_back("Linear interpolation"); | 160 desc.valueNames.push_back("Linear interpolation"); |
161 list.push_back(desc); | 161 list.push_back(desc); |
162 | 162 |
163 return list; | 163 return list; |
196 } else if (param == "tuning") { | 196 } else if (param == "tuning") { |
197 m_tuningFrequency = value; | 197 m_tuningFrequency = value; |
198 } else if (param == "bpo") { | 198 } else if (param == "bpo") { |
199 m_bpo = lrintf(value); | 199 m_bpo = lrintf(value); |
200 } else if (param == "interpolation") { | 200 } else if (param == "interpolation") { |
201 m_interpolation = (CQInterpolated::Interpolation)lrintf(value); | 201 m_interpolation = (CQSpectrogram::Interpolation)lrintf(value); |
202 } else { | 202 } else { |
203 std::cerr << "WARNING: CQVamp::setParameter: unknown parameter \"" | 203 std::cerr << "WARNING: CQVamp::setParameter: unknown parameter \"" |
204 << param << "\"" << std::endl; | 204 << param << "\"" << std::endl; |
205 } | 205 } |
206 } | 206 } |
222 m_minFrequency = Pitch::getFrequencyForPitch | 222 m_minFrequency = Pitch::getFrequencyForPitch |
223 (m_minMIDIPitch, 0, m_tuningFrequency); | 223 (m_minMIDIPitch, 0, m_tuningFrequency); |
224 m_maxFrequency = Pitch::getFrequencyForPitch | 224 m_maxFrequency = Pitch::getFrequencyForPitch |
225 (m_maxMIDIPitch, 0, m_tuningFrequency); | 225 (m_maxMIDIPitch, 0, m_tuningFrequency); |
226 | 226 |
227 m_cq = new CQInterpolated | 227 m_cq = new CQSpectrogram |
228 (m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo, | 228 (m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo, |
229 m_interpolation); | 229 m_interpolation); |
230 | 230 |
231 return true; | 231 return true; |
232 } | 232 } |
234 void | 234 void |
235 CQVamp::reset() | 235 CQVamp::reset() |
236 { | 236 { |
237 if (m_cq) { | 237 if (m_cq) { |
238 delete m_cq; | 238 delete m_cq; |
239 m_cq = new CQInterpolated | 239 m_cq = new CQSpectrogram |
240 (m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo, | 240 (m_inputSampleRate, m_minFrequency, m_maxFrequency, m_bpo, |
241 m_interpolation); | 241 m_interpolation); |
242 } | 242 } |
243 m_prevFeature.clear(); | 243 m_prevFeature.clear(); |
244 m_haveStartTime = false; | 244 m_haveStartTime = false; |
312 } | 312 } |
313 | 313 |
314 CQVamp::FeatureSet | 314 CQVamp::FeatureSet |
315 CQVamp::getRemainingFeatures() | 315 CQVamp::getRemainingFeatures() |
316 { | 316 { |
317 vector<vector<double> > cqout = m_cq->getRemainingBlocks(); | 317 vector<vector<double> > cqout = m_cq->getRemainingOutput(); |
318 return convertToFeatures(cqout); | 318 return convertToFeatures(cqout); |
319 } | 319 } |
320 | 320 |
321 CQVamp::FeatureSet | 321 CQVamp::FeatureSet |
322 CQVamp::convertToFeatures(const vector<vector<double> > &cqout) | 322 CQVamp::convertToFeatures(const vector<vector<double> > &cqout) |