Audacity 3.2.0
Namespaces | Functions
RiffTestUtil.cpp File Reference
#include "AcidizerTags.h"
#include "LibsndfileTagger.h"
#include "sndfile.h"
#include <fstream>
#include <iostream>
#include <optional>
Include dependency graph for RiffTestUtil.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{RiffTestUtil.cpp}
 

Functions

void anonymous_namespace{RiffTestUtil.cpp}::PrintHelp (const char *const *argv)
 
int main (int argc, char *const *argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char *const *  argv 
)

Definition at line 60 of file RiffTestUtil.cpp.

61{
62 using namespace LibImportExport;
63
64 if (argc < 5)
65 {
67 return 1;
68 }
69
70 const std::string inputFile = argv[1];
71 auto duration = 0.;
72 try
73 {
74 duration = std::stod(argv[2]);
75 }
76 catch (std::invalid_argument& e)
77 {
78 std::cout << "Invalid duration: " << argv[2] << std::endl;
80 return 1;
81 }
82
83 Test::LibsndfileTagger tagger { duration, inputFile };
84 if (!tagger)
85 {
86 std::cout << "Failed to open file: " << inputFile << std::endl;
87 return 1;
88 }
89
90 enum class Mode
91 {
92 Unknown,
93 MuseHub,
94 SoundForge,
95 };
96 const Mode mode = std::string { "MuseHub" } == argv[3] ? Mode::MuseHub :
97 std::string { "SoundForge" } == argv[3] ?
98 Mode::SoundForge :
99 Mode::Unknown;
100 if (mode == Mode::Unknown)
101 {
102 std::cout << "Unknown mode: " << argv[3] << std::endl;
104 return 1;
105 }
106
107 const auto isOneShot = argc >= 5 && std::string { "one-shot" } == argv[4];
108 if (isOneShot)
109 tagger.AddAcidizerTags(Test::AcidizerTags::OneShot {});
110 else if (mode == Mode::MuseHub)
111 try
112 {
113 const auto bpm = std::stod(argv[4]);
114 tagger.AddAcidizerTags(Test::AcidizerTags::Loop { bpm });
115 tagger.AddDistributorInfo("Muse Hub");
116 }
117 catch (std::invalid_argument& e)
118 {
119 std::cout << "Invalid BPM: " << argv[4] << std::endl;
121 return 1;
122 }
123 else
124 try
125 {
126 const auto numBeats = std::stoi(argv[4]);
127 tagger.AddAcidizerTags(Test::AcidizerTags::Beats { numBeats });
128 }
129 catch (std::invalid_argument& e)
130 {
131 std::cout << "Invalid number of beats: " << argv[5] << std::endl;
133 return 1;
134 }
135
136 return 0;
137}
When adding tags, the allocated memory must be preserved until the file is closed....
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.
void PrintHelp(const char *const *argv)

References CommandLineArgs::argc, CommandLineArgs::argv, and anonymous_namespace{RiffTestUtil.cpp}::PrintHelp().

Here is the call graph for this function: