Mercurial > hg > sonic-visualiser
comparison transform/RealTimePluginTransform.cpp @ 55:ca1e3f5657d5
* Simplify maker names in plugin menu
* Make sure derived models have a name (based on the transform)
* Don't start deriving a model from a derived model until the derived model is
ready
* Tidy up completion management in writable wave file model
* Make writable models save/reload correctly from session file (i.e.
regenerating from the original transform)
* Same for dense 3d models -- don't save the data, just the transform details
* Add a comment describing the SV file format
author | Chris Cannam |
---|---|
date | Fri, 13 Oct 2006 12:51:05 +0000 |
parents | 527598e2fa10 |
children | bedc7517b6e8 |
comparison
equal
deleted
inserted
replaced
54:ec77936c268e | 55:ca1e3f5657d5 |
---|---|
22 | 22 |
23 #include "data/model/Model.h" | 23 #include "data/model/Model.h" |
24 #include "data/model/SparseTimeValueModel.h" | 24 #include "data/model/SparseTimeValueModel.h" |
25 #include "data/model/DenseTimeValueModel.h" | 25 #include "data/model/DenseTimeValueModel.h" |
26 #include "data/model/WritableWaveFileModel.h" | 26 #include "data/model/WritableWaveFileModel.h" |
27 #include "data/model/WaveFileModel.h" | |
27 | 28 |
28 #include <iostream> | 29 #include <iostream> |
29 | 30 |
30 RealTimePluginTransform::RealTimePluginTransform(Model *inputModel, | 31 RealTimePluginTransform::RealTimePluginTransform(Model *inputModel, |
31 QString pluginId, | 32 QString pluginId, |
115 void | 116 void |
116 RealTimePluginTransform::run() | 117 RealTimePluginTransform::run() |
117 { | 118 { |
118 DenseTimeValueModel *input = getInput(); | 119 DenseTimeValueModel *input = getInput(); |
119 if (!input) return; | 120 if (!input) return; |
121 | |
122 while (!input->isReady()) { | |
123 if (dynamic_cast<WaveFileModel *>(input)) break; // no need to wait | |
124 std::cerr << "FeatureExtractionPluginTransform::run: Waiting for input model to be ready..." << std::endl; | |
125 sleep(1); | |
126 } | |
120 | 127 |
121 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *>(m_output); | 128 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *>(m_output); |
122 WritableWaveFileModel *wwfm = dynamic_cast<WritableWaveFileModel *>(m_output); | 129 WritableWaveFileModel *wwfm = dynamic_cast<WritableWaveFileModel *>(m_output); |
123 if (!stvm && !wwfm) return; | 130 if (!stvm && !wwfm) return; |
124 | 131 |
193 | 200 |
194 float **buffers = m_plugin->getAudioOutputBuffers(); | 201 float **buffers = m_plugin->getAudioOutputBuffers(); |
195 | 202 |
196 if (buffers) { | 203 if (buffers) { |
197 | 204 |
198 //!!! This will fail if any buffers[c] is null or | |
199 //uninitialised. The plugin instance should ensure | |
200 //that that can't happen -- but it doesn't | |
201 | |
202 if (blockFrame >= latency) { | 205 if (blockFrame >= latency) { |
203 wwfm->addSamples(buffers, blockSize); | 206 wwfm->addSamples(buffers, blockSize); |
204 } else if (blockFrame + blockSize >= latency) { | 207 } else if (blockFrame + blockSize >= latency) { |
205 size_t offset = latency - blockFrame; | 208 size_t offset = latency - blockFrame; |
206 size_t count = blockSize - offset; | 209 size_t count = blockSize - offset; |
214 } | 217 } |
215 } | 218 } |
216 | 219 |
217 if (blockFrame == startFrame || completion > prevCompletion) { | 220 if (blockFrame == startFrame || completion > prevCompletion) { |
218 if (stvm) stvm->setCompletion(completion); | 221 if (stvm) stvm->setCompletion(completion); |
222 if (wwfm) wwfm->setCompletion(completion); | |
219 prevCompletion = completion; | 223 prevCompletion = completion; |
220 } | 224 } |
221 | 225 |
222 blockFrame += blockSize; | 226 blockFrame += blockSize; |
223 } | 227 } |
224 | 228 |
225 if (stvm) stvm->setCompletion(100); | 229 if (stvm) stvm->setCompletion(100); |
226 if (wwfm) wwfm->sync(); | 230 if (wwfm) wwfm->setCompletion(100); |
227 } | 231 } |
228 | 232 |