| 1439 | } // namespace |
| 1440 | |
| 1441 | bool ProjectFileManager::ImportWithTempoDetection( |
| 1442 | const std::vector<FilePath>& fileNames, bool addToHistory) |
| 1443 | { |
| 1444 | const auto projectWasEmpty = |
| 1445 | TrackList::Get(mProject).Any<WaveTrack>().empty(); |
| 1446 | std::vector<std::shared_ptr<ClipMirAudioReader>> resultingReaders; |
| 1447 | const auto success = std::all_of( |
| 1448 | fileNames.begin(), fileNames.end(), [&](const FilePath& fileName) { |
| 1449 | std::shared_ptr<ClipMirAudioReader> resultingReader; |
| 1450 | const auto success = DoImport(fileName, addToHistory, &resultingReader); |
| 1451 | if (success && resultingReader) |
| 1452 | resultingReaders.push_back(std::move(resultingReader)); |
| 1453 | return success; |
| 1454 | }); |
| 1455 | // At the moment, one failing import doesn't revert the project state, hence |
| 1456 | // we still run the analysis on what was successfully imported. |
| 1457 | // TODO implement reverting of the project state on failure. |
| 1458 | if (!resultingReaders.empty()) |
| 1459 | { |
| 1460 | const auto pProj = mProject.shared_from_this(); |
| 1461 | BasicUI::CallAfter([=] { |
| 1462 | AudacityMirProject mirInterface { *pProj }; |
| 1463 | const auto analyzedClips = |
| 1464 | RunTempoDetection(resultingReaders, mirInterface, projectWasEmpty); |
| 1465 | MIR::SynchronizeProject(analyzedClips, mirInterface, projectWasEmpty); |
| 1466 | }); |
| 1467 | } |
| 1468 | return success; |
| 1469 | } |
| 1470 | |
| 1471 | bool ProjectFileManager::ImportWithoutTempoDetection( |
| 1472 | const std::vector<FilePath>& fileNames, bool addToHistory) |