comparison data/model/FFTModel.cpp @ 297:c022976d18e8

* Merge from sv-match-alignment branch (excluding alignment-specific document). - add aggregate wave model (not yet complete enough to be added as a true model in a layer, but there's potential) - add play solo mode - add alignment model -- unused in plain SV - fix two plugin leaks - add m3u playlist support (opens all files at once, potentially hazardous) - fix retrieval of pre-encoded URLs - add ability to resample audio files on import, so as to match rates with other files previously loaded; add preference for same - add preliminary support in transform code for range and rate of transform input - reorganise preferences dialog, move dark-background option to preferences, add option for temporary directory location
author Chris Cannam
date Fri, 28 Sep 2007 13:56:38 +0000
parents daf89d31f45c
children aa8dbac62024
comparison
equal deleted inserted replaced
296:2b6c99b607f1 297:c022976d18e8
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #include "FFTModel.h" 16 #include "FFTModel.h"
17 #include "DenseTimeValueModel.h" 17 #include "DenseTimeValueModel.h"
18 #include "AggregateWaveModel.h"
18 19
19 #include "base/Profiler.h" 20 #include "base/Profiler.h"
20 #include "base/Pitch.h" 21 #include "base/Pitch.h"
21 22
22 #include <cassert> 23 #include <cassert>
32 //!!! ZoomConstraint! 33 //!!! ZoomConstraint!
33 m_server(0), 34 m_server(0),
34 m_xshift(0), 35 m_xshift(0),
35 m_yshift(0) 36 m_yshift(0)
36 { 37 {
37 m_server = FFTDataServer::getFuzzyInstance(model, 38 setSourceModel(const_cast<DenseTimeValueModel *>(model)); //!!! hmm.
38 channel, 39
39 windowType, 40 m_server = getServer(model,
40 windowSize, 41 channel,
41 windowIncrement, 42 windowType,
42 fftSize, 43 windowSize,
43 polar, 44 windowIncrement,
44 fillFromColumn); 45 fftSize,
46 polar,
47 fillFromColumn);
45 48
46 if (!m_server) return; // caller should check isOK() 49 if (!m_server) return; // caller should check isOK()
47 50
48 size_t xratio = windowIncrement / m_server->getWindowIncrement(); 51 size_t xratio = windowIncrement / m_server->getWindowIncrement();
49 size_t yratio = m_server->getFFTSize() / fftSize; 52 size_t yratio = m_server->getFFTSize() / fftSize;
73 } 76 }
74 77
75 FFTModel::~FFTModel() 78 FFTModel::~FFTModel()
76 { 79 {
77 if (m_server) FFTDataServer::releaseInstance(m_server); 80 if (m_server) FFTDataServer::releaseInstance(m_server);
81 }
82
83 FFTDataServer *
84 FFTModel::getServer(const DenseTimeValueModel *model,
85 int channel,
86 WindowType windowType,
87 size_t windowSize,
88 size_t windowIncrement,
89 size_t fftSize,
90 bool polar,
91 size_t fillFromColumn)
92 {
93 // Obviously, an FFT model of channel C (where C != -1) of an
94 // aggregate model is the same as the FFT model of the appropriate
95 // channel of whichever model that aggregate channel is drawn
96 // from. We should use that model here, in case we already have
97 // the data for it or will be wanting the same data again later.
98
99 // If the channel is -1 (i.e. mixture of all channels), then we
100 // can't do this shortcut unless the aggregate model only has one
101 // channel or contains exactly all of the channels of a single
102 // other model. That isn't very likely -- if it were the case,
103 // why would we be using an aggregate model?
104
105 if (channel >= 0) {
106
107 const AggregateWaveModel *aggregate =
108 dynamic_cast<const AggregateWaveModel *>(model);
109
110 if (aggregate && channel < aggregate->getComponentCount()) {
111
112 AggregateWaveModel::ModelChannelSpec spec =
113 aggregate->getComponent(channel);
114
115 return getServer(spec.model,
116 spec.channel,
117 windowType,
118 windowSize,
119 windowIncrement,
120 fftSize,
121 polar,
122 fillFromColumn);
123 }
124 }
125
126 // The normal case
127
128 return FFTDataServer::getFuzzyInstance(model,
129 channel,
130 windowType,
131 windowSize,
132 windowIncrement,
133 fftSize,
134 polar,
135 fillFromColumn);
78 } 136 }
79 137
80 size_t 138 size_t
81 FFTModel::getSampleRate() const 139 FFTModel::getSampleRate() const
82 { 140 {