| 423 | |
| 424 | |
| 425 | void 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()); |
nothing calls this directly
no test coverage detected