YARP
Yet Another Robot Platform
yarp::sig::Sound Class Reference

Class for storing sounds. More...

#include <yarp/sig/Sound.h>

+ Inheritance diagram for yarp::sig::Sound:

Detailed Description

Class for storing sounds.

Examples:
portaudio/sound_receiver.cpp, and portaudio/sound_sender_mic.cpp.

Definition at line 28 of file Sound.h.

Public Member Functions

 Sound (int bytesPerSample=2)
 
 Sound (const Sound &alt)
 Copy constructor. More...
 
virtual ~Sound ()
 
const Soundoperator= (const Sound &alt)
 Assignment operator. More...
 
Soundoperator+= (const Sound &alt)
 Addition assignment operator. More...
 
Sound subSound (size_t first_sample, size_t last_sample)
 Returns a subpart of the sound. More...
 
void resize (size_t samples, size_t channels=1)
 
int get (size_t sample, size_t channel=0) const
 
void set (int value, size_t sample, size_t channel=0)
 
int getSafe (size_t sample, size_t channel=0)
 
void setSafe (int value, size_t sample, size_t channel=0)
 
bool isSample (size_t sample, size_t channel=0) const
 Check whether a sample lies within the sound. More...
 
void clear ()
 set all the samples to zero (silence) More...
 
size_t getFrequency () const
 
void setFrequency (size_t freq)
 
size_t getBytesPerSample () const
 
size_t getSamples () const
 
size_t getChannels () const
 
virtual bool read (yarp::os::ConnectionReader &connection) override
 Read this object from a network connection. More...
 
virtual bool write (yarp::os::ConnectionWriter &connection) const override
 Write this object to a network connection. More...
 
unsigned char * getRawData () const
 
size_t getRawDataSize () const
 
- Public Member Functions inherited from yarp::os::Portable
virtual Type getType () const
 
- Public Member Functions inherited from yarp::os::PortReader
virtual ~PortReader ()
 Destructor. More...
 
virtual Type getReadType () const
 
- Public Member Functions inherited from yarp::os::PortWriter
virtual ~PortWriter ()
 Destructor. More...
 
virtual void onCompletion () const
 This is called when the port has finished all writing operations. More...
 
virtual void onCommencement () const
 This is called when the port is about to begin writing operations. More...
 
virtual yarp::os::Type getWriteType () const
 

Private Member Functions

void init (size_t bytesPerSample)
 
void synchronize ()
 

Private Attributes

void * implementation
 
size_t samples
 
size_t channels
 
size_t bytesPerSample
 
size_t frequency
 

Additional Inherited Members

- Static Public Member Functions inherited from yarp::os::Portable
static bool copyPortable (PortWriter &writer, PortReader &reader)
 Copy one portable to another, via writing and reading. More...
 

Constructor & Destructor Documentation

◆ Sound() [1/2]

Sound::Sound ( int  bytesPerSample = 2)

Definition at line 26 of file Sound.cpp.

◆ Sound() [2/2]

Sound::Sound ( const Sound alt)

Copy constructor.

Clones the content of another sound.

Parameters
altthe image to sound

Definition at line 31 of file Sound.cpp.

◆ ~Sound()

Sound::~Sound ( )
virtual

Definition at line 146 of file Sound.cpp.

Member Function Documentation

◆ clear()

void Sound::clear ( )

set all the samples to zero (silence)

Definition at line 169 of file Sound.cpp.

◆ get()

int Sound::get ( size_t  sample,
size_t  channel = 0 
) const

Definition at line 159 of file Sound.cpp.

◆ getBytesPerSample()

size_t yarp::sig::Sound::getBytesPerSample ( ) const
inline

Definition at line 99 of file Sound.h.

◆ getChannels()

size_t yarp::sig::Sound::getChannels ( ) const
inline

Definition at line 103 of file Sound.h.

◆ getFrequency()

size_t Sound::getFrequency ( ) const

Definition at line 186 of file Sound.cpp.

◆ getRawData()

unsigned char * Sound::getRawData ( ) const

Definition at line 213 of file Sound.cpp.

◆ getRawDataSize()

size_t Sound::getRawDataSize ( ) const

Definition at line 218 of file Sound.cpp.

◆ getSafe()

int yarp::sig::Sound::getSafe ( size_t  sample,
size_t  channel = 0 
)
inline

Definition at line 67 of file Sound.h.

◆ getSamples()

size_t yarp::sig::Sound::getSamples ( ) const
inline

Definition at line 101 of file Sound.h.

◆ init()

void Sound::init ( size_t  bytesPerSample)
private

Definition at line 133 of file Sound.cpp.

◆ isSample()

bool yarp::sig::Sound::isSample ( size_t  sample,
size_t  channel = 0 
) const
inline

Check whether a sample lies within the sound.

Parameters
samplethe sample to choose
channelthe channel to choose
Returns
true iff there is a sample at the given coordinate

Definition at line 86 of file Sound.h.

◆ operator+=()

Sound & Sound::operator+= ( const Sound alt)

Addition assignment operator.

Appends a sound to another sound (internal memory reallocation)

Parameters
altthe sound to append

Definition at line 40 of file Sound.cpp.

◆ operator=()

const Sound & Sound::operator= ( const Sound alt)

Assignment operator.

Clones the content of another sound.

Parameters
altthe image to sound

Definition at line 78 of file Sound.cpp.

◆ read()

bool Sound::read ( yarp::os::ConnectionReader reader)
overridevirtual

Read this object from a network connection.

Override this for your particular class.

Parameters
readeran interface to the network connection for reading
Returns
true iff the object is successfully read

Implements yarp::os::Portable.

Definition at line 194 of file Sound.cpp.

◆ resize()

void Sound::resize ( size_t  samples,
size_t  channels = 1 
)

Definition at line 153 of file Sound.cpp.

◆ set()

void Sound::set ( int  value,
size_t  sample,
size_t  channel = 0 
)

Definition at line 176 of file Sound.cpp.

◆ setFrequency()

void Sound::setFrequency ( size_t  freq)

Definition at line 190 of file Sound.cpp.

◆ setSafe()

void yarp::sig::Sound::setSafe ( int  value,
size_t  sample,
size_t  channel = 0 
)
inline

Definition at line 74 of file Sound.h.

◆ subSound()

Sound Sound::subSound ( size_t  first_sample,
size_t  last_sample 
)

Returns a subpart of the sound.

Parameters
first_samplethe starting sample number
last_samplethe ending sample number

Definition at line 94 of file Sound.cpp.

◆ synchronize()

void Sound::synchronize ( )
private

Definition at line 88 of file Sound.cpp.

◆ write()

bool Sound::write ( yarp::os::ConnectionWriter writer) const
overridevirtual

Write this object to a network connection.

Override this for your particular class. Be aware that depending on the nature of the connections a port has, and what protocol they use, and how efficient the YARP implementation is, this method may be called once, twice, or many times, as the result of a single call to Port::write

Parameters
writeran interface to the network connection for writing
Returns
true iff the object is successfully written

Implements yarp::os::Portable.

Definition at line 205 of file Sound.cpp.

Member Data Documentation

◆ bytesPerSample

size_t yarp::sig::Sound::bytesPerSample
private

Definition at line 120 of file Sound.h.

◆ channels

size_t yarp::sig::Sound::channels
private

Definition at line 119 of file Sound.h.

◆ frequency

size_t yarp::sig::Sound::frequency
private

Definition at line 121 of file Sound.h.

◆ implementation

void* yarp::sig::Sound::implementation
private

Definition at line 117 of file Sound.h.

◆ samples

size_t yarp::sig::Sound::samples
private

Definition at line 118 of file Sound.h.


The documentation for this class was generated from the following files: