Audacity 3.2.0
Functions | Variables
MIR::anonymous_namespace{TatumQuantizationFitBenchmarking.cpp} Namespace Reference

Functions

std::vector< std::string > GetBenchmarkingAudioFiles ()
 
std::string Pretty (const std::string &filename)
 

Variables

const auto datasetRoot
 

Function Documentation

◆ GetBenchmarkingAudioFiles()

std::vector< std::string > MIR::anonymous_namespace{TatumQuantizationFitBenchmarking.cpp}::GetBenchmarkingAudioFiles ( )

Definition at line 26 of file TatumQuantizationFitBenchmarking.cpp.

27{
28 std::vector<std::string> files;
29#if USE_FILESYSTEM
30 namespace fs = std::filesystem;
31 for (const auto& entry : fs::directory_iterator(datasetRoot))
32 for (const auto& subEntry : fs::recursive_directory_iterator(entry))
33 if (
34 subEntry.is_regular_file() && subEntry.path().extension() == ".mp3")
35 files.push_back(subEntry.path().string());
36#else
37 // Recursively find all files in the dataset directory with .mp3 extension,
38 // not using std::filesystem:
39 // https://stackoverflow.com/questions/612097/how-can-i-get-the-list-of-files-in-a-directory-using-c-or-c
40 const auto command = "find -H " + datasetRoot + " -type f -name '*.mp3' -print";
41 FILE* pipe = popen(command.c_str(), "r");
42 if (!pipe)
43 throw std::runtime_error("popen() failed!");
44 constexpr auto bufferSize = 512;
45 char buffer[bufferSize];
46 while (fgets(buffer, bufferSize, pipe) != nullptr)
47 {
48 std::string file(buffer);
49 file.erase(file.find_last_not_of("\n") + 1);
50 files.push_back(file);
51 }
52 const auto returnCode = pclose(pipe);
53 if (returnCode != 0)
54 throw std::runtime_error("pclose() failed!");
55#endif
56 std::sort(files.begin(), files.end());
57 return files;
58}
static ProjectFileIORegistry::AttributeWriterEntry entry

References datasetRoot, and entry.

Referenced by MIR::TEST_CASE().

Here is the caller graph for this function:

◆ Pretty()

std::string MIR::anonymous_namespace{TatumQuantizationFitBenchmarking.cpp}::Pretty ( const std::string &  filename)

Definition at line 60 of file TatumQuantizationFitBenchmarking.cpp.

61{
62 // Remove the dataset root from the filename ...
63 const auto datasetRootLength = datasetRoot.length();
64 auto tmp = filename.substr(datasetRootLength + 1);
65 // ... and now the .mp3 extension:
66 tmp = tmp.substr(0, tmp.length() - 4);
67 // Replace backslashes with forward slashes:
68 std::replace(tmp.begin(), tmp.end(), '\\', '/');
69 return tmp;
70}

References datasetRoot.

Referenced by MIR::TEST_CASE().

Here is the caller graph for this function:

Variable Documentation

◆ datasetRoot

const auto MIR::anonymous_namespace{TatumQuantizationFitBenchmarking.cpp}::datasetRoot
Initial value:
=
std::string(CMAKE_CURRENT_SOURCE_DIR) + "/benchmarking-dataset"

Definition at line 23 of file TatumQuantizationFitBenchmarking.cpp.

Referenced by GetBenchmarkingAudioFiles(), and Pretty().