Mercurial > hg > svcore
comparison transform/RealTimeEffectModelTransformer.cpp @ 1429:48e9f538e6e9
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:22 +0000 |
parents | e994747fb9dd |
children | fde8c497373f |
comparison
equal
deleted
inserted
replaced
1428:87ae75da6527 | 1429:48e9f538e6e9 |
---|---|
48 QString pluginId = transform.getPluginIdentifier(); | 48 QString pluginId = transform.getPluginIdentifier(); |
49 | 49 |
50 // SVDEBUG << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << output << endl; | 50 // SVDEBUG << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << output << endl; |
51 | 51 |
52 RealTimePluginFactory *factory = | 52 RealTimePluginFactory *factory = |
53 RealTimePluginFactory::instanceFor(pluginId); | 53 RealTimePluginFactory::instanceFor(pluginId); |
54 | 54 |
55 if (!factory) { | 55 if (!factory) { |
56 cerr << "RealTimeEffectModelTransformer: No factory available for plugin id \"" | 56 cerr << "RealTimeEffectModelTransformer: No factory available for plugin id \"" |
57 << pluginId << "\"" << endl; | 57 << pluginId << "\"" << endl; |
58 return; | 58 return; |
59 } | 59 } |
60 | 60 |
61 DenseTimeValueModel *input = getConformingInput(); | 61 DenseTimeValueModel *input = getConformingInput(); |
62 if (!input) return; | 62 if (!input) return; |
63 | 63 |
65 input->getSampleRate(), | 65 input->getSampleRate(), |
66 transform.getBlockSize(), | 66 transform.getBlockSize(), |
67 input->getChannelCount()); | 67 input->getChannelCount()); |
68 | 68 |
69 if (!m_plugin) { | 69 if (!m_plugin) { |
70 cerr << "RealTimeEffectModelTransformer: Failed to instantiate plugin \"" | 70 cerr << "RealTimeEffectModelTransformer: Failed to instantiate plugin \"" |
71 << pluginId << "\"" << endl; | 71 << pluginId << "\"" << endl; |
72 return; | 72 return; |
73 } | 73 } |
74 | 74 |
75 TransformFactory::getInstance()->setPluginParameters(transform, m_plugin); | 75 TransformFactory::getInstance()->setPluginParameters(transform, m_plugin); |
76 | 76 |
77 if (m_outputNo >= 0 && | 77 if (m_outputNo >= 0 && |
91 (input->getSampleRate(), outputChannels); | 91 (input->getSampleRate(), outputChannels); |
92 | 92 |
93 m_outputs.push_back(model); | 93 m_outputs.push_back(model); |
94 | 94 |
95 } else { | 95 } else { |
96 | 96 |
97 SparseTimeValueModel *model = new SparseTimeValueModel | 97 SparseTimeValueModel *model = new SparseTimeValueModel |
98 (input->getSampleRate(), transform.getBlockSize(), 0.0, 0.0, false); | 98 (input->getSampleRate(), transform.getBlockSize(), 0.0, 0.0, false); |
99 | 99 |
100 if (m_units != "") model->setScaleUnits(m_units); | 100 if (m_units != "") model->setScaleUnits(m_units); |
101 | 101 |
110 | 110 |
111 DenseTimeValueModel * | 111 DenseTimeValueModel * |
112 RealTimeEffectModelTransformer::getConformingInput() | 112 RealTimeEffectModelTransformer::getConformingInput() |
113 { | 113 { |
114 DenseTimeValueModel *dtvm = | 114 DenseTimeValueModel *dtvm = |
115 dynamic_cast<DenseTimeValueModel *>(getInputModel()); | 115 dynamic_cast<DenseTimeValueModel *>(getInputModel()); |
116 if (!dtvm) { | 116 if (!dtvm) { |
117 SVDEBUG << "RealTimeEffectModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl; | 117 SVDEBUG << "RealTimeEffectModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl; |
118 } | 118 } |
119 return dtvm; | 119 return dtvm; |
120 } | 120 } |
121 | 121 |
122 void | 122 void |
181 sv_frame_t latency = m_plugin->getLatency(); | 181 sv_frame_t latency = m_plugin->getLatency(); |
182 | 182 |
183 while (blockFrame < contextStart + contextDuration + latency && | 183 while (blockFrame < contextStart + contextDuration + latency && |
184 !m_abandoned) { | 184 !m_abandoned) { |
185 | 185 |
186 int completion = int | 186 int completion = int |
187 ((((blockFrame - contextStart) / blockSize) * 99) / | 187 ((((blockFrame - contextStart) / blockSize) * 99) / |
188 (1 + ((contextDuration) / blockSize))); | 188 (1 + ((contextDuration) / blockSize))); |
189 | 189 |
190 sv_frame_t got = 0; | 190 sv_frame_t got = 0; |
191 | 191 |
192 if (channelCount == 1) { | 192 if (channelCount == 1) { |
193 if (inbufs && inbufs[0]) { | 193 if (inbufs && inbufs[0]) { |
194 auto data = input->getData | 194 auto data = input->getData |
195 (m_input.getChannel(), blockFrame, blockSize); | 195 (m_input.getChannel(), blockFrame, blockSize); |
196 got = data.size(); | 196 got = data.size(); |
197 for (sv_frame_t i = 0; i < got; ++i) { | 197 for (sv_frame_t i = 0; i < got; ++i) { |
204 for (sv_frame_t i = 0; i < blockSize; ++i) { | 204 for (sv_frame_t i = 0; i < blockSize; ++i) { |
205 inbufs[ch][i] = inbufs[0][i]; | 205 inbufs[ch][i] = inbufs[0][i]; |
206 } | 206 } |
207 } | 207 } |
208 } | 208 } |
209 } else { | 209 } else { |
210 if (inbufs && inbufs[0]) { | 210 if (inbufs && inbufs[0]) { |
211 auto data = input->getMultiChannelData | 211 auto data = input->getMultiChannelData |
212 (0, channelCount - 1, blockFrame, blockSize); | 212 (0, channelCount - 1, blockFrame, blockSize); |
213 if (!data.empty()) got = data[0].size(); | 213 if (!data.empty()) got = data[0].size(); |
214 for (int ch = 0; ch < channelCount; ++ch) { | 214 for (int ch = 0; ch < channelCount; ++ch) { |
226 for (sv_frame_t i = 0; i < blockSize; ++i) { | 226 for (sv_frame_t i = 0; i < blockSize; ++i) { |
227 inbufs[ch][i] = inbufs[ch % channelCount][i]; | 227 inbufs[ch][i] = inbufs[ch % channelCount][i]; |
228 } | 228 } |
229 } | 229 } |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 /* | 233 /* |
234 cerr << "Input for plugin: " << m_plugin->getAudioInputCount() << " channels "<< endl; | 234 cerr << "Input for plugin: " << m_plugin->getAudioInputCount() << " channels "<< endl; |
235 | 235 |
236 for (int ch = 0; ch < m_plugin->getAudioInputCount(); ++ch) { | 236 for (int ch = 0; ch < m_plugin->getAudioInputCount(); ++ch) { |
279 delete[] tmp; | 279 delete[] tmp; |
280 } | 280 } |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 if (blockFrame == contextStart || completion > prevCompletion) { | 284 if (blockFrame == contextStart || completion > prevCompletion) { |
285 // This setCompletion is probably misusing the completion | 285 // This setCompletion is probably misusing the completion |
286 // terminology, just as it was for WritableWaveFileModel | 286 // terminology, just as it was for WritableWaveFileModel |
287 if (stvm) stvm->setCompletion(completion); | 287 if (stvm) stvm->setCompletion(completion); |
288 if (wwfm) wwfm->setWriteProportion(completion); | 288 if (wwfm) wwfm->setWriteProportion(completion); |
289 prevCompletion = completion; | 289 prevCompletion = completion; |
290 } | 290 } |
291 | 291 |
292 blockFrame += blockSize; | 292 blockFrame += blockSize; |
293 } | 293 } |
294 | 294 |
295 if (m_abandoned) return; | 295 if (m_abandoned) return; |
296 | 296 |
297 if (stvm) stvm->setCompletion(100); | 297 if (stvm) stvm->setCompletion(100); |