libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
libscratchcpp::Sound Class Reference

The Sound class represents a Scratch sound. More...

#include <scratchcpp/sound.h>

Inheritance diagram for libscratchcpp::Sound:
Collaboration diagram for libscratchcpp::Sound:

Public Types

enum class  Effect { Pitch , Pan }
 

Public Member Functions

 Sound (const std::string &name, const std::string &id, const std::string &format)
 
 Sound (const Sound &)=delete
 
virtual ~Sound ()
 
int rate () const
 
void setRate (int newRate)
 
int sampleCount () const
 
void setSampleCount (int newSampleCount)
 
virtual void setVolume (double volume)
 
virtual void setEffect (Effect effect, double value)
 
virtual void start (Thread *owner=nullptr)
 
virtual void stop ()
 
virtual bool isPlaying () const
 
std::shared_ptr< Soundclone () const
 
Threadowner () const
 
void setId (const std::string &id)
 
const std::string & name () const
 
const std::string & fileName () const
 
const std::string & dataFormat () const
 
const void * data () const
 
unsigned int dataSize () const
 
void setData (unsigned int size, void *data)
 
Targettarget () const
 
void setTarget (Target *target)
 
const std::string & id () const
 

Protected Member Functions

void processData (unsigned int size, void *data) override
 
virtual bool isClone () const override
 

Detailed Description

The Sound class represents a Scratch sound.

Member Enumeration Documentation

◆ Effect

enum class libscratchcpp::Sound::Effect
strong
Enumerator
Pitch 
Pan 

Constructor & Destructor Documentation

◆ Sound() [1/2]

Sound::Sound ( const std::string & name,
const std::string & id,
const std::string & format )

Constructs Sound.

◆ Sound() [2/2]

libscratchcpp::Sound::Sound ( const Sound & )
delete

◆ ~Sound()

virtual libscratchcpp::Sound::~Sound ( )
inlinevirtual

Member Function Documentation

◆ clone()

std::shared_ptr< Sound > Sound::clone ( ) const

Returns an independent copy of the sound which is valid for as long as the original sound exists.

◆ data()

const void * Asset::data ( ) const
inherited

Returns the asset data.

◆ dataFormat()

const std::string & Asset::dataFormat ( ) const
inherited

Returns the name of the format of the asset file.

◆ dataSize()

unsigned int Asset::dataSize ( ) const
inherited

Returns the size of the asset data.

◆ fileName()

const std::string & Asset::fileName ( ) const
inherited

Returns the name of the asset file.

◆ id()

const std::string & Entity::id ( ) const
inherited

Returns the ID.

◆ isClone()

bool Sound::isClone ( ) const
overrideprotectedvirtual

Reimplemented from libscratchcpp::Asset.

◆ isPlaying()

bool Sound::isPlaying ( ) const
virtual

Returns true if the sound is being played.

◆ name()

const std::string & Asset::name ( ) const
inherited

Returns the name of the asset.

◆ owner()

Thread * Sound::owner ( ) const

◆ processData()

void Sound::processData ( unsigned int size,
void * data )
overrideprotectedvirtual

Reimplemented from libscratchcpp::Asset.

◆ rate()

int Sound::rate ( ) const

Returns the sampling rate of the sound in Hertz.

◆ sampleCount()

int Sound::sampleCount ( ) const

Returns the number of samples.

◆ setData()

void Asset::setData ( unsigned int size,
void * data )
inherited

Sets the asset data (will be deallocated when the object is destroyed).

◆ setEffect()

void Sound::setEffect ( Effect effect,
double value )
virtual

Sets the value of the given sound effect.

◆ setId()

void Asset::setId ( const std::string & id)
inherited

Sets the ID (MD5 hash) of the asset file.

◆ setRate()

void Sound::setRate ( int newRate)

Sets the sampling rate of the sound in Hertz.

◆ setSampleCount()

void Sound::setSampleCount ( int newSampleCount)

Sets the number of samples.

◆ setTarget()

void Asset::setTarget ( Target * target)
inherited

Sets the sprite or stage this asset belongs to.

◆ setVolume()

void Sound::setVolume ( double volume)
virtual

Sets the volume percentage of the sound.

◆ start()

void Sound::start ( Thread * owner = nullptr)
virtual

Starts the playback of the sound.

◆ stop()

void Sound::stop ( )
virtual

Stops the playback of the sound.

◆ target()

Target * Asset::target ( ) const
inherited

Returns the sprite or stage this asset belongs to.


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