|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
26 #ifdef DEBUG_TIME_SPENT
52 if (config.
check(
"subdevice", name)) {
64 yCError(SERVERSOUNDGRABBER,
"\"--subdevice <name>\" not set for server_soundgrabber");
71 yCError(SERVERSOUNDGRABBER,
"cannot make <%s>", name->
toString().c_str());
76 yCError(SERVERSOUNDGRABBER,
"failed to open interface");
81 std::string portname =
"/sound_grabber";
82 if (config.
check(
"name", name)) {
85 if (streamingPort.
open(portname) ==
false) {
86 yCError(SERVERSOUNDGRABBER) <<
"Unable to open port" << portname;
91 if (rpcPort.
open(portname +
"/rpc") ==
false) {
92 yCError(SERVERSOUNDGRABBER) <<
"Unable to open port" << portname +
"/rpc";
108 if (mic !=
nullptr) {
113 streamingPort.
close();
125 #ifdef DEBUG_TIME_SPENT
127 yCDebug(SERVERSOUNDGRABBER) << current_time - last_time;
128 last_time = current_time;
131 if (mic !=
nullptr) {
133 #ifdef PRINT_DEBUG_MESSAGES
135 audio_buffer_size buf_max;
136 audio_buffer_size buf_cur;
139 yCDebug(SERVERSOUNDGRABBER) <<
"BEFORE Buffer status:" << buf_cur.getBytes() <<
"/" << buf_max.getBytes() <<
"bytes";
142 mic->
getSound(snd, 44100, 44100, 0.0);
143 #ifdef PRINT_DEBUG_MESSAGES
145 audio_buffer_size buf_max;
146 audio_buffer_size buf_cur;
149 yCDebug(SERVERSOUNDGRABBER) <<
"AFTER Buffer status:" << buf_cur.getBytes() <<
"/" << buf_max.getBytes() <<
"bytes";
152 #ifdef PRINT_DEBUG_MESSAGES
158 streamingPort.
write(snd);
161 yCInfo(SERVERSOUNDGRABBER,
"Sound grabber stopping");
168 bool ok = command.
read(connection);
184 yCError(SERVERSOUNDGRABBER) <<
"Invalid command";
189 if (returnToSender !=
nullptr) {
190 reply.
write(*returnToSender);
void close() override
Stop port activity.
A simple collection of objects that can be described and transmitted in a portable way.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
void clear()
Empties the bottle of any objects it contains.
A base class for nested structures that can be searched.
bool close() override
Close the DeviceDriver.
size_t getSamples() const
Get the number of samples contained in the sound.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
bool isValid() const
Check if device is valid.
#define YARP_LOG_COMPONENT(name,...)
bool view(T *&x)
Get an interface to the device driver.
size_t getChannels() const
Get the number of channels of the sound.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
virtual bool getRecordingAudioBufferMaxSize(yarp::dev::AudioBufferSize &size)=0
bool open(yarp::os::Searchable &config) override
Configure with a set of options.
virtual bool startRecording()=0
Start the recording.
bool open(const std::string &txt)
Construct and configure a device by its common name.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
virtual bool isString() const
Checks if value is a string.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
An interface for writing to a network connection.
static void delaySystem(double seconds)
virtual std::string asString() const
Get string value.
virtual bool getRecordingAudioBufferCurrentSize(yarp::dev::AudioBufferSize &size)=0
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
void setReader(PortReader &reader) override
Set an external reader for port data.
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
constexpr yarp::conf::vocab32_t VOCAB_ERR
An interface for reading from a network connection.
#define yCError(component,...)
~ServerSoundGrabber() override
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
bool isStopping()
Returns true if the thread is stopping (Thread::stop has been called).
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
#define yCInfo(component,...)
#define yCDebug(component,...)
Class for storing sounds.
void run() override
Main body of the new thread.
virtual bool getSound(yarp::sig::Sound &sound, size_t min_number_of_samples, size_t max_number_of_samples, double max_samples_timeout_s)=0
Get a sound from a device.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
void interrupt() override
Interrupt any current reads or writes attached to the port.
bool start()
Start the new thread running.
virtual bool stopRecording()=0
Stop the recording.
size_t getBytesPerSample() const
Get the number of bytes per sample.
std::string toString() const override
Return a standard text representation of the content of the object.
A single value (typically within a Bottle).
bool stop()
Stop the thread.
constexpr yarp::conf::vocab32_t VOCAB_OK
A class for storing options and configuration information.