HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
hart_cliconfig.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include "dependencies/CLI11/CLI11.hpp"
5
6namespace hart
7{
8
9/// @brief Holds values set by the user via CLI interface
10/// @details It's mostly intended for the internal use, but you may access it in your own test cases as well
11/// @ingroup TestRunner
13{
14public:
15 /// @brief Get the singleton instance
17 {
18 static CLIConfig cfg;
19 return cfg;
20 }
21
22 /// @brief Inits the CLI arguments
24 {
25 app.add_option ("--data-root-path,-d", m_dataRootPath, "Data root path");
26 app.add_option ("--tags,-t", m_tags, "Test tags");
27 app.add_option ("--seed,-s", m_seed, "Random seed")->default_val (0);
28
29 app.add_option (
30 "--lin-decimals",
31 m_linDecimals,
32 "Number of displayed decimal places for samples' linear values in test output"
33 )->default_val (6);
34
35 app.add_option (
36 "--db-decimals",
37 m_dbDecimals,
38 "Number of displayed decimal places for values in decidels in test output"
39 )->default_val (1);
40
41 app.add_option (
42 "--sec-decimals",
43 m_secDecimals,
44 "Number of displayed decimal places for values in seconds in test output"
45 )->default_val (3);
46
47 app.add_option (
48 "--hz-decimals",
49 m_hzDecimals,
50 "Number of displayed decimal places for values in hertz in test output"
51 )->default_val (1);
52
53 app.add_option (
54 "--rad-decimals",
55 m_radDecimals,
56 "Number of displayed decimal places for values in radians in test output"
57 )->default_val (1);
58
59 app.add_option (
60 "--cents-decimals",
61 m_centsDecimals,
62 "Number of displayed decimal places for values in cents in test output"
63 )->default_val (0);
64
65 app.add_option (
66 "--block-size",
67 m_defaultBlockSizeFrames,
68 "Default max block size in frames (samples). All tests will run with this block size, unless other value is explicitly set via withBlockSize()."
69 )->default_val (1024);
70
71 app.add_option (
72 "--input-channels",
73 m_defaultNumInputChannels,
74 "Default number of input channels. All tests will run with this number of output channels, unless other value is explicitly selected via withOutputChannels() or a similar modifier."
75 )->default_val (1);
76
77 app.add_option (
78 "--output-channels",
79 m_defaultNumOutputChannels,
80 "Default number of output channels. All tests will run with this number of input channels, unless other value is explicitly selected via withInputChannels() or a similar modifier."
81 )->default_val (1);
82
83 app.add_option (
84 "--sample-rate",
85 m_defaultSampleRateHz,
86 "Default sample rate in Hz. All tests will run with this sample rate, unless other value is explicitly stated via withSampleRate()."
87 )->default_val (44100.0);
88
89 app.add_option (
90 "--render-duration",
91 m_defaultRenderDurationSeconds,
92 "Default render duration in seconds. All tests will render this amount of audio (excluding optional warm-up time), unless explicitly overridden with withDuration()."
93 )->default_val (0.1);
94
95 app.add_flag ("--run-generators,-g", m_runGeneratorsNotTests, "Run generators instead of tests");
96 app.add_flag ("--shuffle", m_shuffle, "Shuffle task order. Obeys --seed value.");
97 }
98
99 CLI::App& getCLIApp() { return app; }
100
101 /// @brief Get data root path set by a "`--data-root-path`,`-d`" argument
102 std::string getDataRootPath() { return m_dataRootPath; }
103
104 /// @brief Gets random seed set by a "`--seed`/`-s`" argument
105 /// @details You can use it in your test cases to keep your own random-ness dependent on the global random seed
106 uint_fast32_t getRandomSeed() { return m_seed; }
107
108 /// @see linPrecision
109 int getLinDecimals() { return m_linDecimals; }
110
111 /// @see dbPrecision
112 int getDbDecimals() { return m_dbDecimals; }
113
114 /// @see secPrecision
115 int getSecDecimals() { return m_secDecimals; }
116
117 /// @see hzPrecision
118 int getHzDecimals() { return m_hzDecimals; }
119
120 /// @see radPrecision
121 int getRadDecimals() { return m_radDecimals; }
122
123 /// @see centsPrecision
124 int getCentsDecimals() { return m_centsDecimals; }
125
126 bool shouldRunGenerators() { return m_runGeneratorsNotTests; }
127 bool shouldShuffleTasks() { return m_shuffle; }
128 std::string& getTags() { return m_tags; }
129
130 size_t getGefaultBlockSizeFrames() const { return m_defaultBlockSizeFrames; }
131 size_t getDefaultNumInputChannels() const { return m_defaultNumInputChannels; }
132 size_t getDefaultNumOutputChannels() const { return m_defaultNumOutputChannels; }
133 double getDefaultSampleRateHz() const { return m_defaultSampleRateHz; }
134 double getDefaultRenderDurationSeconds() const { return m_defaultRenderDurationSeconds; }
135
136private:
137 CLI::App app { "HART" };
138
139 std::string m_dataRootPath = ".";
140 std::string m_tags = "";
141 uint_fast32_t m_seed = 0;
142 bool m_runGeneratorsNotTests = false;
143 bool m_shuffle = false;
144
145 int m_linDecimals = 0;
146 int m_dbDecimals = 0;
147 int m_secDecimals = 0;
148 int m_hzDecimals = 0;
149 int m_radDecimals = 0;
150 int m_centsDecimals = 0;
151
152 size_t m_defaultBlockSizeFrames = 1024;
153 size_t m_defaultNumInputChannels = 1;
154 size_t m_defaultNumOutputChannels = 1;
155 double m_defaultSampleRateHz = 44100.0;
156 double m_defaultRenderDurationSeconds = 0.1;
157
158 CLIConfig() = default;
159};
160
161} // namespace hart
Holds values set by the user via CLI interface.
double getDefaultRenderDurationSeconds() const
size_t getDefaultNumOutputChannels() const
uint_fast32_t getRandomSeed()
Gets random seed set by a "`--seed`/`-s`" argument.
std::string getDataRootPath()
Get data root path set by a "`--data-root-path`,`-d`" argument.
size_t getDefaultNumInputChannels() const
double getDefaultSampleRateHz() const
size_t getGefaultBlockSizeFrames() const
CLI::App & getCLIApp()
void initCommandLineArgs()
Inits the CLI arguments.
std::string & getTags()
static CLIConfig & getInstance()
Get the singleton instance.