P-E-R-R-Y
Utilitaires, contrats et vendors du moteur, en une seule doc
Loading...
Searching...
No Matches
RaySound Class Reference

Raylib Sound class - a LoadSoundAlias() of a RaySoundBuffer, does not own the buffer. Deleting the sound never touches the buffer. More...

#include <RaySound.hpp>

Inheritance diagram for RaySound:
Collaboration diagram for RaySound:

Public Member Functions

 RaySound (RaySoundBuffer &buffer)
 ~RaySound () override
bool isReady () const override
void play () override
 Fires the sound from the beginning.
void pause () override
 Suspends the sound without touching the position.
void stop () override
 Stops the sound AND rewinds to zero.
void setVolume (float volume) override
 set the volume of the sound
float getVolume () const override
 get the volume of the sound
void setPosition (Vector3f position) override
 set the 3D position of the sound, for backends that spatialize against a listener. A backend without real spatial audio may just store this and keep playing at full volume - a no-op here still leaves a usable sound, unlike a fake 3D model with nothing to render.
Vector3f getPosition () const override
 get the 3D position of the sound
void setVelocity (Vector3f velocity) override
 set the velocity of the sound, used by backends that apply a doppler effect
Vector3f getVelocity () const override
 get the velocity of the sound
Public Member Functions inherited from audio::ISound
virtual ~ISound ()=default

Detailed Description

Raylib Sound class - a LoadSoundAlias() of a RaySoundBuffer, does not own the buffer. Deleting the sound never touches the buffer.

play() restarts the sound, where raylib would overlap playbacks by default. This is the only deliberate divergence from IMusic::play() : an ISound is a one-shot, not a transport.

Constructor & Destructor Documentation

◆ RaySound()

RaySound::RaySound ( RaySoundBuffer & buffer)
inline

◆ ~RaySound()

RaySound::~RaySound ( )
inlineoverride

Member Function Documentation

◆ getPosition()

Vector3f RaySound::getPosition ( ) const
inlineoverridevirtual

get the 3D position of the sound

Returns
Vector3f

Implements audio::ISound.

◆ getVelocity()

Vector3f RaySound::getVelocity ( ) const
inlineoverridevirtual

get the velocity of the sound

Returns
Vector3f

Implements audio::ISound.

◆ getVolume()

float RaySound::getVolume ( ) const
inlineoverridevirtual

get the volume of the sound

Returns
float

Implements audio::ISound.

◆ isReady()

bool RaySound::isReady ( ) const
inlineoverridevirtual

Implements audio::ISound.

◆ pause()

void RaySound::pause ( )
inlineoverridevirtual

Suspends the sound without touching the position.

Does nothing if the sound is not playing. Idempotent.

Implements audio::ISound.

◆ play()

void RaySound::play ( )
inlineoverridevirtual

Fires the sound from the beginning.

The ONLY deliberate divergence from IMusic::play() : an ISound is a one-shot, not a transport. play() on a sound already playing RESTARTS it from zero - that is what lets a gunshot retrigger faster than its own duration. IMusic, by contrast, ignores a play() while playing.

The difference is written here because it is intended. It cannot be guessed from the signature, and both vendors have to honour it identically.

Implements audio::ISound.

◆ setPosition()

void RaySound::setPosition ( Vector3f position)
inlineoverridevirtual

set the 3D position of the sound, for backends that spatialize against a listener. A backend without real spatial audio may just store this and keep playing at full volume - a no-op here still leaves a usable sound, unlike a fake 3D model with nothing to render.

Parameters
position

Implements audio::ISound.

◆ setVelocity()

void RaySound::setVelocity ( Vector3f velocity)
inlineoverridevirtual

set the velocity of the sound, used by backends that apply a doppler effect

Parameters
velocity

Implements audio::ISound.

◆ setVolume()

void RaySound::setVolume ( float volume)
inlineoverridevirtual

set the volume of the sound

Parameters
volume

Implements audio::ISound.

◆ stop()

void RaySound::stop ( )
inlineoverridevirtual

Stops the sound AND rewinds to zero.

Does nothing if the sound is already stopped. Idempotent.

Implements audio::ISound.


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