34 QPushButton* startButton =
nullptr;
35 QPushButton* stopButton =
nullptr;
36 QVBoxLayout* vlayout =
nullptr;
37 QHBoxLayout* hlayout =
nullptr;
38 QLabel* label =
nullptr;
44 hlayout->removeWidget(startButton);
45 hlayout->removeWidget(stopButton);
46 if (startButton) {
delete startButton; startButton =
nullptr;}
47 if (stopButton) {
delete stopButton; stopButton =
nullptr;}
48 vlayout->removeWidget(label);
49 if (label) {
delete label; label =
nullptr; }
50 vlayout->removeItem(hlayout);
51 if (vlayout) {
delete vlayout; vlayout =
nullptr;}
52 if (hlayout) {
delete hlayout; hlayout =
nullptr;}
57 startButton =
new QPushButton(
"Start",
this);
58 stopButton =
new QPushButton(
"Stop",
this);
59 vlayout =
new QVBoxLayout;
60 hlayout =
new QHBoxLayout;
61 label =
new QLabel(
"Device status: - - -");
62 hlayout->addWidget(startButton);
63 hlayout->addWidget(stopButton);
64 vlayout->addLayout(hlayout);
65 vlayout->addWidget(label);
80 if (enabled) label->setText(
"Device status : recording");
81 else label->setText(
"Device status : idle");
87 if (enabled) label->setText(
"Device status : playing");
88 else label->setText(
"Device status : idle");
110 m_iAudioRec = audio_rec_interface;
111 m_iAudioPlay = audio_play_interface;
120#define ERROR_RETURN_CODE 0
121int main(
int argc,
char *argv[])
126 freopen(
"CONOUT$",
"w", stdout);
127 freopen(
"CONOUT$",
"w", stderr);
132 if (!
yarp.checkNetwork())
134 yError(
"Error initializing yarp network (is yarpserver running?)");
141 if (rf.
check(
"help"))
143 yInfo() <<
"yarpaudiocontrolgui accepts the following options:";
144 yInfo() <<
"--local <portname> an optional parameter which defines the name of the local port. Default is /yarpaudiocontrolgui. Multiple yarpaudiocontrolgui must use different local names.";
145 yInfo() <<
"--remote-rec <portname> an optional parameter which defines the name of the rpc port of a audioRecorder_nws_yarp device.";
146 yInfo() <<
"--remote-play <portname> an optional parameter which defines the name of the rpc port of a audioPlayer_nws_yarp device.";
147 yInfo() <<
"NOTE: remote-rec and remote-play options are mutually exclusive.";
152 std::string remote_rec = rf.
find(
"remote-rec").
asString();
153 std::string remote_play = rf.
find(
"remote-play").
asString();
154 if (local.empty()) { local =
"/yarpaudiocontrolgui"; }
155 if (remote_play.empty() && remote_rec.empty())
157 yError() <<
"Please choose at least a recorder or a player device. Use --help for list of options.";
160 if (!remote_play.empty() && !remote_rec.empty())
162 yError() <<
"Please choose either a recorder or a player device, not both. remote-rec and remote-play options are mutually exclusive.";
172 if (!remote_play.empty())
175 p_cfgPlay.
put(
"device",
"audioPlayer_nwc_yarp");
176 p_cfgPlay.
put(
"remote", remote_play);
177 p_cfgPlay.
put(
"local", local);
178 ddPlay.
open(p_cfgPlay);
179 ddPlay.
view(iAudioPlay);
180 if (iAudioPlay ==
nullptr)
182 yError()<<
"Failed to open audioPlayerInterface";
186 if (!remote_rec.empty())
189 p_cfgRec.
put(
"device",
"audioRecorder_nwc_yarp");
190 p_cfgRec.
put(
"remote", remote_rec);
191 p_cfgRec.
put(
"local", local);
192 ddRec.
open(p_cfgRec);
193 ddRec.
view(iAudioRec);
194 if (iAudioRec ==
nullptr)
196 yError() <<
"Failed to open audioRecorderInterface";
202 QApplication app(argc, argv);
205 widget->setMinimumWidth(400);
210 if (widget) {
delete widget; widget =
nullptr;}
214 yInfo() <<
"yarpaudiocontrolgui says goodbye!";
bool view(T *&x)
Get an interface to the device driver.
Read a YARP-format sound block from a device.
virtual yarp::dev::ReturnValue stopRecording()=0
Stop the recording.
virtual yarp::dev::ReturnValue isRecording(bool &recording_enabled)=0
Check if the recording has been enabled (e.g.
virtual yarp::dev::ReturnValue startRecording()=0
Start the recording.
Interface for rendering a YARP-format sound and controlling its reproduction ona device.
virtual yarp::dev::ReturnValue startPlayback()=0
Start the playback.
virtual yarp::dev::ReturnValue stopPlayback()=0
Stop the playback.
virtual yarp::dev::ReturnValue isPlaying(bool &playback_enabled)=0
Check if the playback has been enabled (e.g.
A container for a device driver.
bool close() override
Close the DeviceDriver.
bool open(const std::string &txt)
Construct and configure a device by its common name.
Utilities for manipulating the YARP network, including initialization and shutdown.
A class for storing options and configuration information.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Helper class for finding config files and other external resources.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
bool configure(int argc, char *argv[], bool skipFirstArgument=true)
Sets up the ResourceFinder.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
An abstraction for a thread of execution.
bool stop()
Stop the thread.
bool isStopping()
Returns true if the thread is stopping (Thread::stop has been called).
bool start()
Start the new thread running.
virtual std::string asString() const
Get string value.
int main(int argc, char *argv[])
#define ERROR_RETURN_CODE
void delay(double seconds)
Wait for a certain number of seconds.
The main, catch-all namespace for YARP.