YARP  2.3.68+272-20170522.1+git50f0ae7
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:

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

Private Member Functions

void init (int bytesPerSample)
 
void synchronize ()
 

Private Attributes

void * implementation
 
int samples
 
int channels
 
int bytesPerSample
 
int 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...
 

Detailed Description

Class for storing sounds.

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

Definition at line 25 of file Sound.h.

Constructor & Destructor Documentation

◆ Sound() [1/2]

Sound::Sound ( int  bytesPerSample = 2)

Definition at line 23 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 28 of file Sound.cpp.

◆ ~Sound()

Sound::~Sound ( )
virtual

Definition at line 143 of file Sound.cpp.

Member Function Documentation

◆ clear()

void Sound::clear ( )

set all the samples to zero (silence)

Definition at line 166 of file Sound.cpp.

◆ get()

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

Definition at line 156 of file Sound.cpp.

◆ getBytesPerSample()

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

Definition at line 96 of file Sound.h.

◆ getChannels()

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

Definition at line 100 of file Sound.h.

◆ getFrequency()

int Sound::getFrequency ( ) const

Definition at line 183 of file Sound.cpp.

◆ getRawData()

unsigned char * Sound::getRawData ( ) const

Definition at line 210 of file Sound.cpp.

◆ getRawDataSize()

int Sound::getRawDataSize ( ) const

Definition at line 215 of file Sound.cpp.

◆ getSafe()

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

Definition at line 64 of file Sound.h.

◆ getSamples()

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

Definition at line 98 of file Sound.h.

◆ init()

void Sound::init ( int  bytesPerSample)
private

Definition at line 129 of file Sound.cpp.

◆ isSample()

bool yarp::sig::Sound::isSample ( int  sample,
int  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 83 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 37 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 70 of file Sound.cpp.

◆ read()

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

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 191 of file Sound.cpp.

◆ resize()

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

Definition at line 150 of file Sound.cpp.

◆ set()

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

Definition at line 173 of file Sound.cpp.

◆ setFrequency()

void Sound::setFrequency ( int  freq)

Definition at line 187 of file Sound.cpp.

◆ setSafe()

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

Definition at line 71 of file Sound.h.

◆ subSound()

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

Returns a subpart of the sound.

Parameters
first_samplethe starting sample number
last_samplethe ending sample number

Definition at line 86 of file Sound.cpp.

◆ synchronize()

void Sound::synchronize ( )
private

Definition at line 80 of file Sound.cpp.

◆ write()

bool Sound::write ( yarp::os::ConnectionWriter writer)
virtual

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 202 of file Sound.cpp.

Member Data Documentation

◆ bytesPerSample

int yarp::sig::Sound::bytesPerSample
private

Definition at line 117 of file Sound.h.

◆ channels

int yarp::sig::Sound::channels
private

Definition at line 116 of file Sound.h.

◆ frequency

int yarp::sig::Sound::frequency
private

Definition at line 118 of file Sound.h.

◆ implementation

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

Definition at line 114 of file Sound.h.

◆ samples

int yarp::sig::Sound::samples
private

Definition at line 115 of file Sound.h.


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