MCPcopy Create free account
hub / github.com/LMMS/lmms / processAutomations

Method processAutomations

src/core/Song.cpp:425–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423
424
425void Song::processAutomations(const TrackList &tracklist, MidiTime timeStart, fpp_t)
426{
427 AutomatedValueMap values;
428
429 QSet<const AutomatableModel*> recordedModels;
430
431 TrackContainer* container = this;
432 int tcoNum = -1;
433
434 switch (m_playMode)
435 {
436 case Mode_PlaySong:
437 break;
438 case Mode_PlayBB:
439 {
440 Q_ASSERT(tracklist.size() == 1);
441 Q_ASSERT(tracklist.at(0)->type() == Track::BBTrack);
442 auto bbTrack = dynamic_cast<BBTrack*>(tracklist.at(0));
443 auto bbContainer = Engine::getBBTrackContainer();
444 container = bbContainer;
445 tcoNum = bbTrack->index();
446 }
447 break;
448 default:
449 return;
450 }
451
452 values = container->automatedValuesAt(timeStart, tcoNum);
453 TrackList tracks = container->tracks();
454
455 Track::tcoVector tcos;
456 for (Track* track : tracks)
457 {
458 if (track->type() == Track::AutomationTrack) {
459 track->getTCOsInRange(tcos, 0, timeStart);
460 }
461 }
462
463 // Process recording
464 for (TrackContentObject* tco : tcos)
465 {
466 auto p = dynamic_cast<AutomationPattern *>(tco);
467 MidiTime relTime = timeStart - p->startPosition();
468 if (p->isRecording() && relTime >= 0 && relTime < p->length())
469 {
470 const AutomatableModel* recordedModel = p->firstObject();
471 p->recordValue(relTime, recordedModel->value<float>());
472
473 recordedModels << recordedModel;
474 }
475 }
476
477 // Apply values
478 for (auto it = values.begin(); it != values.end(); it++)
479 {
480 if (! recordedModels.contains(it.key()))
481 {
482 it.key()->setAutomatedValue(it.value());

Callers

nothing calls this directly

Calls 15

getBBTrackContainerFunction · 0.85
indexMethod · 0.80
tracksMethod · 0.80
getTCOsInRangeMethod · 0.80
firstObjectMethod · 0.80
recordValueMethod · 0.80
keyMethod · 0.80
setAutomatedValueMethod · 0.80
sizeMethod · 0.45
typeMethod · 0.45
automatedValuesAtMethod · 0.45
isRecordingMethod · 0.45

Tested by

no test coverage detected