1 #ifndef HULA_CLI_COMMON_H 2 #define HULA_CLI_COMMON_H 6 #define STR_HELPER(x) #x 7 #define STR(x) STR_HELPER(x) 17 #include <QCoreApplication> 18 #include <QTextStream> 20 #include <HulaVersion.h> 24 #define HL_CLI_NAME "hulaloop-cli" 25 #define HL_CLI_ASCII_HEADER "\n" \ 27 " | | | | | | | |\n" \ 28 " | |__| |_ _| | __ _| | ___ ___ _ __\n" \ 29 " | __ | | | | |/ _` | | / _ \\ / _ \\| '_ \\\n" \ 30 " | | | | |_| | | (_| | |___| (_) | (_) | |_) |\n" \ 31 " |_| |_|\\__,_|_|\\__,_|______\\___/ \\___/| .__/\n" \ 34 "----------------------------------------------------\n\n" \ 39 #define QCOL(stream, width, text) \ 40 stream.setFieldWidth(width); \ 42 stream.setFieldWidth(0); 50 Q_DECLARE_TR_FUNCTIONS(
CLI)
61 bool startRecord =
false;
74 std::string delay =
"0";
85 std::string duration = STR(HL_INFINITE_RECORD);
122 QTextStream cout(stdout);
123 cout.setAutoDetectUnicode(
true);
124 cout.setRealNumberNotation(QTextStream::FixedNotation);
125 cout.setRealNumberPrecision(2);
126 cout.setPadChar(
'.');
127 cout.setFieldAlignment(QTextStream::AlignLeft);
131 std::vector<Device *> devices;
142 for (
size_t i = 0; i < devices.size(); i++)
144 QCOL(cout, colW, CLI::tr(
"Device #%1").arg(i).append(
" "));
145 cout <<
" " << devices[i]->getName().c_str() << endl;
147 QCOL(cout, colW, CLI::tr(
"Record",
"device capability").append(
" "));
148 cout <<
" " << ((devices[i]->getType() & DeviceType::RECORD) ? CLI::tr(
"Yes") : CLI::tr(
"No")) << endl;
150 QCOL(cout, colW, CLI::tr(
"Loopback",
"device capability").append(
" "));
151 cout <<
" " << ((devices[i]->getType() & DeviceType::LOOPBACK) ? CLI::tr(
"Yes") : CLI::tr(
"No")) << endl;
153 QCOL(cout, colW, CLI::tr(
"Output",
"device capability").append(
" "));
154 cout <<
" " << ((devices[i]->getType() & DeviceType::PLAYBACK) ? CLI::tr(
"Yes") : CLI::tr(
"No")) << endl;
178 std::vector<Device *> devices;
191 id = std::stoi(name,
nullptr);
193 catch (std::invalid_argument &e)
199 for (
size_t i = 0; i < devices.size(); i++)
202 if (i ==
id || devices[i]->getName() == name)
210 if (device !=
nullptr)
212 device =
new Device(*device);
217 if (device ==
nullptr)
220 fprintf(stderr,
"\n%s\n", qPrintable(CLI::tr(
"Could not find device matching: %1").arg(name.c_str())));
233 QTextStream cout(stdout);
234 cout.setAutoDetectUnicode(
true);
235 cout.setRealNumberNotation(QTextStream::FixedNotation);
236 cout.setRealNumberPrecision(2);
237 cout.setFieldAlignment(QTextStream::AlignLeft);
243 QCOL(cout, colW, CLI::tr(
"Output file:",
"setting"));
248 QCOL(cout, colW, CLI::tr(
"Delay:"));
249 cout << stod(args.
delay) <<
" " << CLI::tr(
"s",
"abbreviation for seconds") << endl;
251 QCOL(cout, colW, CLI::tr(
"Duration:"));
252 cout << stod(args.
duration) <<
" " << CLI::tr(
"s",
"abbreviation for seconds") << endl;
254 QCOL(cout, colW, CLI::tr(
"Sample rate:"));
255 cout << settings->
getSampleRate() <<
" " << CLI::tr(
"Hz",
"unit") << endl;
258 QCOL(cout, colW, CLI::tr(
"Encoding:"));
259 cout <<
"WAV" << endl;
261 QCOL(cout, colW, CLI::tr(
"Input device:"));
262 cout << QString::fromStdString(args.
inputDevice) << endl;
264 QCOL(cout, colW, CLI::tr(
"Output device:"));
265 cout << QString::fromStdString(args.
outputDevice) << endl;
269 #endif // END HULA_CLI_COMMON_H
Device * findDevice(Transport *t, const std::string &name, DeviceType type)
Utility function for searching the list of devices.
Definition: CLICommon.h:175
Extra class for managing the state of the application and all audio related processes.
Definition: Transport.h:33
Controller * getController() const
Get the controller instance.
Definition: Transport.cpp:181
Definition: CLICommon.h:49
static void deleteDevices(std::vector< Device * > devices)
Delete all the device pointers inside the vector.
Definition: Device.cpp:54
std::vector< Device * > getDevices(DeviceType type) const
Fetch a list of devices for the given DeviceType.
Definition: Controller.cpp:116
static HulaSettings * getInstance()
Retreive the singular instance of HulaSettings or construct a new one if none exists.
Definition: HulaSettings.cpp:31
void printDeviceList(Transport *t)
Utility CLI function to print the device list to the console.
Definition: CLICommon.h:117
void printSettings(const HulaImmediateArgs &args)
Utility function for printing the current application settings.
Definition: CLICommon.h:229
int getSampleRate()
Get the number of channels for the current global device configuration.
Definition: HulaAudioSettings.cpp:71
Wrapper for OS specific device information.
Definition: Device.h:55
Wrapper around translation functions for Qt.
Definition: Controller.h:10
Singleton class containing all settings for the application.
Definition: HulaSettings.h:23
bool getShowRecordDevices()
Getters.
Definition: HulaAudioSettings.cpp:45
DeviceType
Denotes type of Device.
Definition: Device.h:18
struct hula::HulaImmediateArgs HulaImmediateArgs
Args parsed from CLI flags.