comparison audio/AudioGenerator.cpp @ 616:7d3a6357ce64 avoid-pointer-keys

Use model IDs
author Chris Cannam
date Mon, 13 Aug 2018 16:45:52 +0100
parents 755fc02a1565
children e2715204feaa
comparison
equal deleted inserted replaced
615:755fc02a1565 616:7d3a6357ce64
139 139
140 if (usesClipMixer(model)) { 140 if (usesClipMixer(model)) {
141 ClipMixer *mixer = makeClipMixerFor(model); 141 ClipMixer *mixer = makeClipMixerFor(model);
142 if (mixer) { 142 if (mixer) {
143 QMutexLocker locker(&m_mutex); 143 QMutexLocker locker(&m_mutex);
144 m_clipMixerMap[model] = mixer; 144 m_clipMixerMap[model->getId()] = mixer;
145 return willPlay; 145 return willPlay;
146 } 146 }
147 } 147 }
148 148
149 if (usesContinuousSynth(model)) { 149 if (usesContinuousSynth(model)) {
150 ContinuousSynth *synth = makeSynthFor(model); 150 ContinuousSynth *synth = makeSynthFor(model);
151 if (synth) { 151 if (synth) {
152 QMutexLocker locker(&m_mutex); 152 QMutexLocker locker(&m_mutex);
153 m_continuousSynthMap[model] = synth; 153 m_continuousSynthMap[model->getId()] = synth;
154 return willPlay; 154 return willPlay;
155 } 155 }
156 } 156 }
157 157
158 return false; 158 return false;
167 << playable << " is not a supported model type" 167 << playable << " is not a supported model type"
168 << endl; 168 << endl;
169 return; 169 return;
170 } 170 }
171 171
172 if (m_clipMixerMap.find(model) == m_clipMixerMap.end()) return; 172 if (m_clipMixerMap.find(model->getId()) == m_clipMixerMap.end()) {
173 return;
174 }
173 175
174 ClipMixer *mixer = makeClipMixerFor(model); 176 ClipMixer *mixer = makeClipMixerFor(model);
175 if (mixer) { 177 if (mixer) {
176 QMutexLocker locker(&m_mutex); 178 QMutexLocker locker(&m_mutex);
177 m_clipMixerMap[model] = mixer; 179 m_clipMixerMap[model->getId()] = mixer;
178 } 180 }
179 } 181 }
180 182
181 bool 183 bool
182 AudioGenerator::usesClipMixer(const Model *model) 184 AudioGenerator::usesClipMixer(const Model *model)
277 dynamic_cast<SparseOneDimensionalModel *>(model); 279 dynamic_cast<SparseOneDimensionalModel *>(model);
278 if (!sodm) return; // nothing to do 280 if (!sodm) return; // nothing to do
279 281
280 QMutexLocker locker(&m_mutex); 282 QMutexLocker locker(&m_mutex);
281 283
282 if (m_clipMixerMap.find(sodm) == m_clipMixerMap.end()) return; 284 if (m_clipMixerMap.find(sodm->getId()) == m_clipMixerMap.end()) {
283 285 return;
284 ClipMixer *mixer = m_clipMixerMap[sodm]; 286 }
285 m_clipMixerMap.erase(sodm); 287
288 ClipMixer *mixer = m_clipMixerMap[sodm->getId()];
289 m_clipMixerMap.erase(sodm->getId());
286 delete mixer; 290 delete mixer;
287 } 291 }
288 292
289 void 293 void
290 AudioGenerator::clearModels() 294 AudioGenerator::clearModels()
305 309
306 #ifdef DEBUG_AUDIO_GENERATOR 310 #ifdef DEBUG_AUDIO_GENERATOR
307 cerr << "AudioGenerator::reset()" << endl; 311 cerr << "AudioGenerator::reset()" << endl;
308 #endif 312 #endif
309 313
310 for (ClipMixerMap::iterator i = m_clipMixerMap.begin(); i != m_clipMixerMap.end(); ++i) { 314 for (ClipMixerMap::iterator i = m_clipMixerMap.begin();
315 i != m_clipMixerMap.end(); ++i) {
311 if (i->second) { 316 if (i->second) {
312 i->second->reset(); 317 i->second->reset();
313 } 318 }
314 } 319 }
315 320
520 sv_frame_t 525 sv_frame_t
521 AudioGenerator::mixClipModel(Model *model, 526 AudioGenerator::mixClipModel(Model *model,
522 sv_frame_t startFrame, sv_frame_t frames, 527 sv_frame_t startFrame, sv_frame_t frames,
523 float **buffer, float gain, float pan) 528 float **buffer, float gain, float pan)
524 { 529 {
525 ClipMixer *clipMixer = m_clipMixerMap[model]; 530 ClipMixer *clipMixer = m_clipMixerMap[model->getId()];
526 if (!clipMixer) return 0; 531 if (!clipMixer) return 0;
527 532
528 int blocks = int(frames / m_processingBlockSize); 533 int blocks = int(frames / m_processingBlockSize);
529 534
530 //!!! todo: the below -- it matters 535 //!!! todo: the below -- it matters
548 #endif 553 #endif
549 554
550 ClipMixer::NoteStart on; 555 ClipMixer::NoteStart on;
551 ClipMixer::NoteEnd off; 556 ClipMixer::NoteEnd off;
552 557
553 NoteOffSet &noteOffs = m_noteOffs[model]; 558 NoteOffSet &noteOffs = m_noteOffs[model->getId()];
554 559
555 float **bufferIndexes = new float *[m_targetChannelCount]; 560 float **bufferIndexes = new float *[m_targetChannelCount];
556 561
557 for (int i = 0; i < blocks; ++i) { 562 for (int i = 0; i < blocks; ++i) {
558 563
679 sv_frame_t frames, 684 sv_frame_t frames,
680 float **buffer, 685 float **buffer,
681 float gain, 686 float gain,
682 float pan) 687 float pan)
683 { 688 {
684 ContinuousSynth *synth = m_continuousSynthMap[model]; 689 ContinuousSynth *synth = m_continuousSynthMap[model->getId()];
685 if (!synth) return 0; 690 if (!synth) return 0;
686 691
687 // only type we support here at the moment 692 // only type we support here at the moment
688 SparseTimeValueModel *stvm = qobject_cast<SparseTimeValueModel *>(model); 693 SparseTimeValueModel *stvm = qobject_cast<SparseTimeValueModel *>(model);
689 if (stvm->getScaleUnits() != "Hz") return 0; 694 if (stvm->getScaleUnits() != "Hz") return 0;