Audacity 3.2.0
Classes | Typedefs | Functions | Variables
anonymous_namespace{ProjectFileManager.cpp} Namespace Reference

Classes

class  CompactDialog
 
class  ImportProgress
 

Typedefs

using Pair = std::pair< const char *, const char * >
 

Functions

wxString FindHelpUrl (const TranslatableString &libraryError)
 
bool ImportProject (AudacityProject &dest, const FilePath &fileName)
 
std::vector< std::shared_ptr< MIR::AnalyzedAudioClip > > RunTempoDetection (const std::vector< std::shared_ptr< ClipMirAudioReader > > &readers, const MIR::ProjectInterface &project, bool projectWasEmpty)
 

Variables

const char *const defaultHelpUrl
 
const Pair helpURLTable []
 

Typedef Documentation

◆ Pair

using anonymous_namespace{ProjectFileManager.cpp}::Pair = typedef std::pair< const char *, const char * >

Definition at line 122 of file ProjectFileManager.cpp.

Function Documentation

◆ FindHelpUrl()

wxString anonymous_namespace{ProjectFileManager.cpp}::FindHelpUrl ( const TranslatableString libraryError)

Definition at line 140 of file ProjectFileManager.cpp.

141{
142 wxString helpUrl;
143 if ( !libraryError.empty() ) {
144 helpUrl = defaultHelpUrl;
145
146 auto msgid = libraryError.MSGID().GET();
147 auto found = std::find_if( begin(helpURLTable), end(helpURLTable),
148 [&]( const Pair &pair ) {
149 return msgid.Contains( pair.first ); }
150 );
151 if (found != end(helpURLTable)) {
152 auto url = found->second;
153 if (url[0] == '#')
154 helpUrl += url;
155 else
156 helpUrl = url;
157 }
158 }
159
160 return helpUrl;
161}
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
Identifier MSGID() const
MSGID is the English lookup key in the catalog, not necessarily for user's eyes if locale is some oth...
std::pair< const char *, const char * > Pair
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References details::begin(), defaultHelpUrl, TranslatableString::empty(), details::end(), Identifier::GET(), helpURLTable, and TranslatableString::MSGID().

Referenced by ProjectFileManager::ReadProjectFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportProject()

bool anonymous_namespace{ProjectFileManager.cpp}::ImportProject ( AudacityProject dest,
const FilePath fileName 
)

Definition at line 1280 of file ProjectFileManager.cpp.

1281{
1283 auto &project = temp.Project();
1284
1285 auto &projectFileIO = ProjectFileIO::Get(project);
1286 if (!projectFileIO.LoadProject(fileName, false))
1287 return false;
1288 auto &srcTracks = TrackList::Get(project);
1289 auto &destTracks = TrackList::Get(dest);
1290 for (const Track *pTrack : srcTracks)
1291 pTrack->PasteInto(dest, destTracks);
1293
1294 return true;
1295}
const auto project
Makes a temporary project that doesn't display on the screen.
AudacityProject & Project()
static ProjectFileIO & Get(AudacityProject &project)
void Merge(const Tags &other)
Definition: Tags.cpp:246
static Tags & Get(AudacityProject &project)
Definition: Tags.cpp:214
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References ProjectFileIO::Get(), Tags::Get(), TrackList::Get(), Tags::Merge(), InvisibleTemporaryProject::Project(), and project.

Referenced by ProjectFileManager::Import().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RunTempoDetection()

std::vector< std::shared_ptr< MIR::AnalyzedAudioClip > > anonymous_namespace{ProjectFileManager.cpp}::RunTempoDetection ( const std::vector< std::shared_ptr< ClipMirAudioReader > > &  readers,
const MIR::ProjectInterface project,
bool  projectWasEmpty 
)

Definition at line 1394 of file ProjectFileManager.cpp.

1397{
1398 const auto isBeatsAndMeasures = project.ViewIsBeatsAndMeasures();
1399 const auto projectTempo = project.GetTempo();
1400
1401 using namespace BasicUI;
1402 auto progress = MakeProgress(
1403 XO("Music Information Retrieval"), XO("Analyzing imported audio"),
1405 auto count = 0;
1406 const auto reportProgress = [&](double progressFraction) {
1407 const auto result = progress->Poll(
1408 (count + progressFraction) / readers.size() * 1000, 1000);
1409 if (result != ProgressResult::Success)
1410 throw UserException {};
1411 };
1412
1413 std::vector<std::shared_ptr<MIR::AnalyzedAudioClip>> analyzedClips;
1414 analyzedClips.reserve(readers.size());
1415 std::transform(
1416 readers.begin(), readers.end(), std::back_inserter(analyzedClips),
1417 [&](const std::shared_ptr<ClipMirAudioReader>& reader) {
1418 const MIR::ProjectSyncInfoInput input {
1419 *reader, reader->filename, reader->tags, reportProgress,
1420 projectTempo, projectWasEmpty, isBeatsAndMeasures,
1421 };
1422 auto syncInfo = MIR::GetProjectSyncInfo(input);
1423 ++count;
1424 return std::make_shared<AnalyzedWaveClip>(reader, syncInfo);
1425 });
1426 return analyzedClips;
1427}
XO("Cut/Copy/Paste")
Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.
Definition: UserException.h:17
@ ProgressShowCancel
Definition: BasicUI.h:142
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Definition: BasicUI.h:294
std::optional< ProjectSyncInfo > GetProjectSyncInfo(const ProjectSyncInfoInput &in)

References MIR::GetProjectSyncInfo(), SpareStrings::input, BasicUI::MakeProgress(), BasicUI::ProgressShowCancel, project, BasicUI::Success, and XO().

Referenced by ProjectFileManager::Import().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ defaultHelpUrl

const char* const anonymous_namespace{ProjectFileManager.cpp}::defaultHelpUrl
Initial value:
=
"FAQ:Errors_on_opening_or_recovering_an_Audacity_project"

Definition at line 119 of file ProjectFileManager.cpp.

Referenced by FindHelpUrl().

◆ helpURLTable

const Pair anonymous_namespace{ProjectFileManager.cpp}::helpURLTable[]
Initial value:
= {
{
"not well-formed (invalid token)",
"Error:_not_well-formed_(invalid_token)_at_line_x"
},
{
"reference to invalid character number",
"Error_Opening_Project:_Reference_to_invalid_character_number_at_line_x"
},
{
"mismatched tag",
"#mismatched"
},
}

Definition at line 123 of file ProjectFileManager.cpp.

Referenced by FindHelpUrl().