YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Sound_marker.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include "Sound_marker.h"
9
10using namespace yarp::os;
11
12namespace {
13YARP_LOG_COMPONENT(SOUND_MARKER, "sound_marker")
14
15} //anonymous namespace
16
17
19{
20 yCDebug(SOUND_MARKER, "created!\n");
21 yCDebug(SOUND_MARKER, "I am attached to the %s\n",
22 (options.find("sender_side").asBool()) ? "sender side" : "receiver side");
23
24 return true;
25}
26
28{
29}
30
32{
33 return false;
34}
35
37{
38 return false;
39}
40
42{
44 if (bt == NULL)
45 {
46 yCWarning(SOUND_MARKER, "expected type Sound but got wrong data type!\n");
47 return false;
48 }
49
50 return true;
51}
52
54{
55 //get data to process
57 if (s == NULL)
58 {
59 yCWarning(SOUND_MARKER, "expected type Sound but got wrong data type!\n");
60 return thing;
61 }
62
63 // add markers at the edges of the sound
64 m_s2 = *s;
65 m_s2.remove_all_markers();
66 m_s2.add_marker("SND_MARKER_START" + std::to_string(marker_counter), 0);
67 m_s2.add_marker("SND_MARKER_END" + std::to_string(marker_counter), s->getSamples()-1);
68
69 yDebug() << m_s2.getMarkersCount();
70
71 //send data
72 m_th.setPortWriter(&m_s2);
73
74 marker_counter++;
75 return m_th;
76}
77
79{
80}
#define yDebug(...)
Definition Log.h:275
void trig() override
This will be called when one of the peer connections to the same import port receives data.
bool setparam(const yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are set via YARP admin port.
yarp::os::Things & update(yarp::os::Things &thing) override
After data get accpeted in the accept() callback, an instance of that is given to the update function...
bool create(const yarp::os::Property &options) override
This will be called when the dll is properly loaded by the portmonitor carrier.
void destroy() override
This will be called when the portmonitor object destroyes.
bool accept(yarp::os::Things &thing) override
This will be called when the data reach the portmonitor object.
bool getparam(yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are requested via YARP admin port.
A mini-server for performing network communication in the background.
A class for storing options and configuration information.
Definition Property.h:32
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Base class for generic things.
Definition Things.h:18
T * cast_as()
Definition Things.h:53
void setPortWriter(yarp::os::PortWriter *writer)
Set the reference to a PortWriter object.
Definition Things.cpp:26
virtual bool asBool() const
Get boolean value.
Definition Value.cpp:186
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:39
size_t getMarkersCount() const
Gets the number of markers contained in the sound.
Definition Sound.cpp:794
void remove_all_markers()
Removes all the markers contained in the sound.
Definition Sound.cpp:789
void add_marker(const std::string &marker_label, size_t sample_id, int channel=-1)
Adds a marker to the sound, identified by a label, a sample id and an optional channel number (if not...
Definition Sound.cpp:757
size_t getSamples() const
Get the number of samples contained in the sound.
Definition Sound.cpp:664
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface to the operating system, including Port based communication.