5 #include <QCommandLineParser> 10 #include "CLICommon.h" 19 #define HL_OUT_FILE_SO "f" 20 #define HL_OUT_FILE_LO "out-file" 21 #define HL_DELAY_TIME_SO "d" 22 #define HL_DELAY_TIME_LO "delay" 23 #define HL_RECORD_TIME_SO "t" 24 #define HL_RECORD_TIME_LO "time" 25 #define HL_TRIGGER_RECORD_SO "r" 26 #define HL_TRIGGER_RECORD_LO "record" 27 #define HL_SAMPLE_RATE_SO "s" 28 #define HL_SAMPLE_RATE_LO "sample-rate" 29 #define HL_ENCODING_SO "e" 30 #define HL_ENCODING_LO "encoding" 31 #define HL_INPUT_DEVICE_SO "i" 32 #define HL_INPUT_DEVICE_LO "input-device" 33 #define HL_OUTPUT_DEVICE_SO "o" 34 #define HL_OUTPUT_DEVICE_LO "output-device" 35 #define HL_LIST_DEVICES_SO "l" 36 #define HL_LIST_DEVICES_LO "list" 40 bool startRecord =
false;
49 void invalidArg(std::string name, QString arg, std::string message =
"")
51 fprintf(stderr,
"Invalid argument '%s' provided to option '%s'.\n", arg.toStdString().c_str(), name.c_str());
52 if (message.size() > 0)
54 fprintf(stderr,
"%s\n", message.c_str());
67 QCommandLineParser parser;
68 parser.setApplicationDescription(
"Simple cross-platform audio loopback and recording.");
70 parser.addHelpOption();
71 parser.addVersionOption();
75 {{HL_OUT_FILE_SO, HL_OUT_FILE_LO}, QCoreApplication::translate(
"main",
"Path to audio output file."), QCoreApplication::translate(
"main",
"out-file-path")},
76 {{HL_DELAY_TIME_SO, HL_DELAY_TIME_LO}, QCoreApplication::translate(
"main",
"Duration, in seconds, of the countdown timer before record."), QCoreApplication::translate(
"main",
"delay")},
77 {{HL_RECORD_TIME_SO, HL_RECORD_TIME_LO}, QCoreApplication::translate(
"main",
"Duration, in seconds, of the record."), QCoreApplication::translate(
"main",
"record duration")},
78 {{HL_TRIGGER_RECORD_SO, HL_TRIGGER_RECORD_LO}, QCoreApplication::translate(
"main",
"Start the countdown/record immediately.")},
79 {{HL_SAMPLE_RATE_SO, HL_SAMPLE_RATE_LO}, QCoreApplication::translate(
"main",
"Desired sample rate of the output file."), QCoreApplication::translate(
"main",
"sample rate")},
81 {{HL_ENCODING_SO, HL_ENCODING_LO}, QCoreApplication::translate(
"main",
"Encoding format for the output file. Valid options are WAV and MP3. This will default to WAV."), QCoreApplication::translate(
"main",
"encoding")},
82 {{HL_INPUT_DEVICE_SO, HL_INPUT_DEVICE_LO}, QCoreApplication::translate(
"main",
"System name of the input device. This will default if not provided."), QCoreApplication::translate(
"main",
"input-device-name")},
83 {{HL_OUTPUT_DEVICE_SO, HL_OUTPUT_DEVICE_LO}, QCoreApplication::translate(
"main",
"System name of the output device. This will default if not provided."), QCoreApplication::translate(
"main",
"output-device-name")},
84 {{HL_LIST_DEVICES_SO, HL_LIST_DEVICES_LO}, QCoreApplication::translate(
"main",
"List available input and output devices.")}
101 if (parser.isSet(HL_OUT_FILE_LO))
106 if (parser.isSet(HL_DELAY_TIME_LO))
109 double delay = parser.value(HL_DELAY_TIME_LO).toDouble(&ok);
112 invalidArg(HL_DELAY_TIME_LO, parser.value(HL_DELAY_TIME_LO));
118 if (parser.isSet(HL_RECORD_TIME_LO))
121 double duration = parser.value(HL_RECORD_TIME_LO).toDouble(&ok);
124 invalidArg(HL_RECORD_TIME_LO, parser.value(HL_RECORD_TIME_LO));
130 if (parser.isSet(HL_TRIGGER_RECORD_LO))
132 extraArgs.startRecord =
true;
135 if (parser.isSet(HL_SAMPLE_RATE_LO))
138 int rate = parser.value(HL_SAMPLE_RATE_LO).toInt(&ok);
141 invalidArg(HL_SAMPLE_RATE_LO, parser.value(HL_SAMPLE_RATE_LO));
147 if (parser.isSet(HL_ENCODING_LO))
149 std::string encoding = parser.value(HL_ENCODING_LO).toStdString();
150 if (encoding ==
"WAV")
156 invalidArg(HL_ENCODING_LO, parser.value(HL_ENCODING_LO),
"Only WAV format is supported at this time.");
161 if (parser.isSet(HL_INPUT_DEVICE_LO))
163 std::string device = parser.value(HL_INPUT_DEVICE_LO).toStdString();
168 if (parser.isSet(HL_OUTPUT_DEVICE_LO))
170 std::string device = parser.value(HL_OUTPUT_DEVICE_LO).toStdString();
175 if (parser.isSet(HL_LIST_DEVICES_LO))
179 printf(
"\n-------- Device List --------\n");
182 extraArgs.exit =
true;
188 #endif // END HL_CLI_ARGS_H
void setDelayTimer(double)
Set the length of the delay timer in seconds.
Definition: HulaAudioSettings.cpp:269
Extra class for managing the state of the application and all audio related processes.
Definition: Transport.h:29
void setRecordDuration(double)
Get the length of the record in seconds.
Definition: HulaAudioSettings.cpp:280
void setOutputFilePath(std::string)
Set the path of the output file specified at startup or during the file save routine.
Definition: HulaAudioSettings.cpp:246
void setSampleRate(int)
Set the number of channels for the current global device configuration.
Definition: HulaAudioSettings.cpp:200
static HulaSettings * getInstance()
Retreive the singular instance of HulaSettings or construct a new one if none exists.
Definition: HulaSettings.cpp:24
void setDefaultInputDeviceName(std::string)
Set the name of the device that should be initially selected for record.
Definition: HulaAudioSettings.cpp:224
void setDefaultOutputDeviceName(std::string)
Set the name of the device that should be initially selected for playback.
Definition: HulaAudioSettings.cpp:235
Definition: Controller.h:11
Singleton class containing all settings for the application.
Definition: HulaSettings.h:12