7#ifndef YARP_SIG_SOUND_H
8#define YARP_SIG_SOUND_H
29 Sound(
size_t bytesPerSample = 2);
68 void overwrite (
const Sound& alt,
size_t offset=0,
size_t len=0);
75 Sound subSound(
size_t first_sample,
size_t last_sample);
82 void resize(
size_t samples,
size_t channels = 1);
84 audio_sample get(
size_t sample,
size_t channel = 0)
const;
86 void set(
audio_sample value,
size_t sample,
size_t channel = 0);
89 if (isSample(sample,channel)) {
90 return get(sample,channel);
95 void setSafe(audio_sample value,
size_t sample,
size_t channel = 0);
103 bool isSample(
size_t sample,
size_t channel = 0)
const;
114 void normalizeChannel(
size_t channel);
126 void amplifyChannel(
size_t channel,
double gain);
132 void amplify(
double gain);
140 void findPeakInChannel(
size_t channelId,
size_t& sampleId, audio_sample& sampleValue)
const;
148 void findPeak(
size_t& channelId,
size_t& sampleId, audio_sample& sampleValue)
const;
155 inline double sample2timestamp(
size_t sampleid)
const {
return static_cast<double>(sampleid / m_frequency);}
162 inline size_t timestamp2sample(
double time)
const {
return static_cast<size_t>(time * m_frequency);}
169 bool clearChannel(
size_t channel);
175 int getFrequency()
const;
180 void setFrequency(
int freq);
186 size_t getBytesPerSample()
const;
192 size_t getSamples()
const;
198 double getDuration()
const;
204 size_t getChannels()
const;
210 Sound extractChannelAsSound(
size_t channel_id)
const;
212 std::vector<std::reference_wrapper<audio_sample>> getChannel(
size_t channel_id);
220 bool replaceChannel(
size_t id,
Sound channel);
228 std::vector<std::reference_wrapper<audio_sample>> getInterleavedAudioRawData()
const;
236 std::vector<std::reference_wrapper<audio_sample>> getNonInterleavedAudioRawData()
const;
251 unsigned char *getRawData()
const;
257 size_t getRawDataSize()
const;
259 void delete_implementation();
267 void init(
size_t bytesPerSample);
272 size_t m_bytesPerSample;
bool operator==(const struct v4l2_control &left, const struct v4l2_control &right)
std::string toString(const T &value)
convert an arbitrary type to string.
RandScalar * implementation(void *t)
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
double sample2timestamp(size_t sampleid) const
Utility function: return the timestamp (in seconds) given the sample id.
size_t timestamp2sample(double time) const
Utility function: return the sample id given the timestamp (in seconds)
audio_sample getSafe(size_t sample, size_t channel=0) const
Vector & operator+=(Vector &a, const double &s)
Addition operator between a scalar and a vector (defined in Math.h).