Mercurial > hg > match-vamp
comparison src/MatchVampPlugin.cpp @ 161:123147f096d2 refactors
Expose tuning frequency parameters through plugin
author | Chris Cannam |
---|---|
date | Thu, 29 Jan 2015 17:13:58 +0000 |
parents | d6c1556fadd0 |
children | dda5410ac9f0 |
comparison
equal
deleted
inserted
replaced
160:581b1118ec28 | 161:123147f096d2 |
---|---|
60 m_frameNo(0), | 60 m_frameNo(0), |
61 m_params(defaultStepTime), | 61 m_params(defaultStepTime), |
62 m_defaultParams(defaultStepTime), | 62 m_defaultParams(defaultStepTime), |
63 m_feParams(inputSampleRate, m_blockSize), | 63 m_feParams(inputSampleRate, m_blockSize), |
64 m_defaultFeParams(inputSampleRate, m_blockSize), | 64 m_defaultFeParams(inputSampleRate, m_blockSize), |
65 m_secondReferenceFrequency(m_defaultFeParams.referenceFrequency), | |
65 m_fcParams(), | 66 m_fcParams(), |
66 m_defaultFcParams(), | 67 m_defaultFcParams(), |
67 m_dParams(), | 68 m_dParams(), |
68 m_defaultDParams() | 69 m_defaultDParams() |
69 { | 70 { |
280 desc.isQuantized = true; | 281 desc.isQuantized = true; |
281 desc.quantizeStep = 1; | 282 desc.quantizeStep = 1; |
282 desc.unit = ""; | 283 desc.unit = ""; |
283 list.push_back(desc); | 284 list.push_back(desc); |
284 | 285 |
286 desc.identifier = "freq1"; | |
287 desc.name = "Tuning Frequency of First Input"; | |
288 desc.description = "Tuning frequency (concert A) for the reference audio."; | |
289 desc.minValue = 220.0; | |
290 desc.maxValue = 880.0; | |
291 desc.defaultValue = (float)m_defaultFeParams.referenceFrequency; | |
292 desc.isQuantized = false; | |
293 desc.unit = "Hz"; | |
294 list.push_back(desc); | |
295 | |
296 desc.identifier = "freq2"; | |
297 desc.name = "Tuning Frequency of Second Input"; | |
298 desc.description = "Tuning frequency (concert A) for the other audio."; | |
299 desc.minValue = 220.0; | |
300 desc.maxValue = 880.0; | |
301 desc.defaultValue = (float)m_defaultFeParams.referenceFrequency; | |
302 desc.isQuantized = false; | |
303 desc.unit = "Hz"; | |
304 list.push_back(desc); | |
305 | |
285 return list; | 306 return list; |
286 } | 307 } |
287 | 308 |
288 float | 309 float |
289 MatchVampPlugin::getParameter(std::string name) const | 310 MatchVampPlugin::getParameter(std::string name) const |
310 return m_fcParams.silenceThreshold; | 331 return m_fcParams.silenceThreshold; |
311 } else if (name == "metric") { | 332 } else if (name == "metric") { |
312 return (int)m_dParams.metric; | 333 return (int)m_dParams.metric; |
313 } else if (name == "noise") { | 334 } else if (name == "noise") { |
314 return m_dParams.noise; | 335 return m_dParams.noise; |
336 } else if (name == "freq1") { | |
337 return (float)m_feParams.referenceFrequency; | |
338 } else if (name == "freq2") { | |
339 return (float)m_secondReferenceFrequency; | |
315 } | 340 } |
316 | 341 |
317 return 0.0; | 342 return 0.0; |
318 } | 343 } |
319 | 344 |
342 m_fcParams.silenceThreshold = value; | 367 m_fcParams.silenceThreshold = value; |
343 } else if (name == "metric") { | 368 } else if (name == "metric") { |
344 m_dParams.metric = (DistanceMetric::Metric)(int(value + 0.1)); | 369 m_dParams.metric = (DistanceMetric::Metric)(int(value + 0.1)); |
345 } else if (name == "noise") { | 370 } else if (name == "noise") { |
346 m_dParams.noise = (DistanceMetric::NoiseAddition)(int(value + 0.1)); | 371 m_dParams.noise = (DistanceMetric::NoiseAddition)(int(value + 0.1)); |
372 } else if (name == "freq1") { | |
373 m_feParams.referenceFrequency = value; | |
374 } else if (name == "freq2") { | |
375 m_secondReferenceFrequency = value; | |
347 } | 376 } |
348 } | 377 } |
349 | 378 |
350 size_t | 379 size_t |
351 MatchVampPlugin::getPreferredStepSize() const | 380 MatchVampPlugin::getPreferredStepSize() const |
363 MatchVampPlugin::createMatchers() | 392 MatchVampPlugin::createMatchers() |
364 { | 393 { |
365 m_params.hopTime = m_stepTime; | 394 m_params.hopTime = m_stepTime; |
366 m_feParams.fftSize = m_blockSize; | 395 m_feParams.fftSize = m_blockSize; |
367 | 396 |
368 m_pipeline = new MatchPipeline(m_feParams, m_fcParams, m_dParams, m_params); | 397 m_pipeline = new MatchPipeline(m_feParams, m_fcParams, m_dParams, m_params, |
398 m_secondReferenceFrequency); | |
369 } | 399 } |
370 | 400 |
371 bool | 401 bool |
372 MatchVampPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize) | 402 MatchVampPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize) |
373 { | 403 { |