Mercurial > hg > sonic-visualiser
comparison transform/FeatureExtractionPluginTransform.cpp @ 3:e764bbf2b090 last-cc-copyright
* Move the current DenseThreeDimensionalModel to EditableDenseThreeDimensionalModel
(wow!), and make DTDM an abstract base
* Move FFTFuzzyAdapter to FFTModel as a new subclass of DTDM
author | Chris Cannam |
---|---|
date | Mon, 31 Jul 2006 17:05:18 +0000 |
parents | 40116f709d3b |
children | d88d117e0c34 |
comparison
equal
deleted
inserted
replaced
2:42a78f0e8fe2 | 3:e764bbf2b090 |
---|---|
21 | 21 |
22 #include "data/model/Model.h" | 22 #include "data/model/Model.h" |
23 #include "base/Window.h" | 23 #include "base/Window.h" |
24 #include "data/model/SparseOneDimensionalModel.h" | 24 #include "data/model/SparseOneDimensionalModel.h" |
25 #include "data/model/SparseTimeValueModel.h" | 25 #include "data/model/SparseTimeValueModel.h" |
26 #include "data/model/DenseThreeDimensionalModel.h" | 26 #include "data/model/EditableDenseThreeDimensionalModel.h" |
27 #include "data/model/DenseTimeValueModel.h" | 27 #include "data/model/DenseTimeValueModel.h" |
28 #include "data/model/NoteModel.h" | 28 #include "data/model/NoteModel.h" |
29 #include "data/fft/FFTFuzzyAdapter.h" | 29 #include "data/model/FFTModel.h" |
30 | 30 |
31 #include <fftw3.h> | 31 #include <fftw3.h> |
32 | 32 |
33 #include <iostream> | 33 #include <iostream> |
34 | 34 |
188 | 188 |
189 m_output = model; | 189 m_output = model; |
190 | 190 |
191 } else { | 191 } else { |
192 | 192 |
193 m_output = new DenseThreeDimensionalModel(modelRate, modelResolution, | 193 m_output = new EditableDenseThreeDimensionalModel |
194 binCount, false); | 194 (modelRate, modelResolution, binCount, false); |
195 | 195 |
196 if (!m_descriptor->binNames.empty()) { | 196 if (!m_descriptor->binNames.empty()) { |
197 std::vector<QString> names; | 197 std::vector<QString> names; |
198 for (size_t i = 0; i < m_descriptor->binNames.size(); ++i) { | 198 for (size_t i = 0; i < m_descriptor->binNames.size(); ++i) { |
199 names.push_back(m_descriptor->binNames[i].c_str()); | 199 names.push_back(m_descriptor->binNames[i].c_str()); |
200 } | 200 } |
201 (dynamic_cast<DenseThreeDimensionalModel *>(m_output)) | 201 (dynamic_cast<EditableDenseThreeDimensionalModel *>(m_output)) |
202 ->setBinNames(names); | 202 ->setBinNames(names); |
203 } | 203 } |
204 } | 204 } |
205 } | 205 } |
206 | 206 |
241 buffers[ch] = new float[m_blockSize]; | 241 buffers[ch] = new float[m_blockSize]; |
242 } | 242 } |
243 | 243 |
244 bool frequencyDomain = (m_plugin->getInputDomain() == | 244 bool frequencyDomain = (m_plugin->getInputDomain() == |
245 Vamp::Plugin::FrequencyDomain); | 245 Vamp::Plugin::FrequencyDomain); |
246 std::vector<FFTFuzzyAdapter *> fftAdapters; | 246 std::vector<FFTModel *> fftModels; |
247 | 247 |
248 if (frequencyDomain) { | 248 if (frequencyDomain) { |
249 for (size_t ch = 0; ch < channelCount; ++ch) { | 249 for (size_t ch = 0; ch < channelCount; ++ch) { |
250 fftAdapters.push_back(new FFTFuzzyAdapter | 250 fftModels.push_back(new FFTModel |
251 (getInput(), | 251 (getInput(), |
252 channelCount == 1 ? m_channel : ch, | 252 channelCount == 1 ? m_channel : ch, |
253 HanningWindow, | 253 HanningWindow, |
254 m_blockSize, | 254 m_blockSize, |
255 m_stepSize, | 255 m_stepSize, |
283 | 283 |
284 for (size_t ch = 0; ch < channelCount; ++ch) { | 284 for (size_t ch = 0; ch < channelCount; ++ch) { |
285 if (frequencyDomain) { | 285 if (frequencyDomain) { |
286 int column = (blockFrame - startFrame) / m_stepSize; | 286 int column = (blockFrame - startFrame) / m_stepSize; |
287 for (size_t i = 0; i < m_blockSize/2; ++i) { | 287 for (size_t i = 0; i < m_blockSize/2; ++i) { |
288 fftAdapters[ch]->getValuesAt | 288 fftModels[ch]->getValuesAt |
289 (column, i, buffers[ch][i*2], buffers[ch][i*2+1]); | 289 (column, i, buffers[ch][i*2], buffers[ch][i*2+1]); |
290 } | 290 } |
291 /*!!! | 291 /*!!! |
292 float sum = 0.0; | 292 float sum = 0.0; |
293 for (size_t i = 0; i < m_blockSize/2; ++i) { | 293 for (size_t i = 0; i < m_blockSize/2; ++i) { |
328 addFeature(blockFrame, feature); | 328 addFeature(blockFrame, feature); |
329 } | 329 } |
330 | 330 |
331 if (frequencyDomain) { | 331 if (frequencyDomain) { |
332 for (size_t ch = 0; ch < channelCount; ++ch) { | 332 for (size_t ch = 0; ch < channelCount; ++ch) { |
333 delete fftAdapters[ch]; | 333 delete fftModels[ch]; |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 setCompletion(100); | 337 setCompletion(100); |
338 } | 338 } |
448 | 448 |
449 } else { | 449 } else { |
450 | 450 |
451 DenseThreeDimensionalModel::BinValueSet values = feature.values; | 451 DenseThreeDimensionalModel::BinValueSet values = feature.values; |
452 | 452 |
453 DenseThreeDimensionalModel *model = getOutput<DenseThreeDimensionalModel>(); | 453 EditableDenseThreeDimensionalModel *model = |
454 getOutput<EditableDenseThreeDimensionalModel>(); | |
454 if (!model) return; | 455 if (!model) return; |
455 | 456 |
456 model->setBinValues(frame, values); | 457 model->setBinValues(frame, values); |
457 } | 458 } |
458 } | 459 } |
484 if (!model) return; | 485 if (!model) return; |
485 model->setCompletion(completion); | 486 model->setCompletion(completion); |
486 | 487 |
487 } else { | 488 } else { |
488 | 489 |
489 DenseThreeDimensionalModel *model = getOutput<DenseThreeDimensionalModel>(); | 490 EditableDenseThreeDimensionalModel *model = |
491 getOutput<EditableDenseThreeDimensionalModel>(); | |
490 if (!model) return; | 492 if (!model) return; |
491 model->setCompletion(completion); | 493 model->setCompletion(completion); |
492 } | 494 } |
493 } | 495 } |
494 | 496 |