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

Une lecture d'un tampon, sur son propre canal. More...

#include <SdlSound.hpp>

Inheritance diagram for SdlSound:
Collaboration diagram for SdlSound:

Public Member Functions

 SdlSound (SdlSoundBuffer &buffer)
 ~SdlSound () 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
 dans [0, 1] comme le contrat, MIX_MAX_VOLUME est un detail de SDL
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
 SdlSound (MIX_Mixer *mixer, SdlSoundBuffer &buffer)
 ~SdlSound () 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
 dans [0, 1] comme le contrat ; MIX_SetTrackGain accepte au-dela
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

Une lecture d'un tampon, sur son propre canal.

Une lecture d'un tampon, sur sa propre piste.

Le canal est reserve au premier play() et garde jusqu'a la destruction : sans ca, pause() et stop() ne sauraient pas quoi arreter.

Chaque son a SA piste, creee a la construction et gardee jusqu'a la fin. Plus de canal a reserver au premier play() ni a verifier avant chaque ordre, comme il le fallait en SDL2 : la piste est a nous, donc pause() et stop() ne peuvent plus toucher le son de quelqu'un d'autre.

Constructor & Destructor Documentation

◆ SdlSound() [1/2]

SdlSound::SdlSound ( SdlSoundBuffer & buffer)
inline

◆ ~SdlSound() [1/2]

SdlSound::~SdlSound ( )
inlineoverride

◆ SdlSound() [2/2]

SdlSound::SdlSound ( MIX_Mixer * mixer,
SdlSoundBuffer & buffer )
inline

◆ ~SdlSound() [2/2]

SdlSound::~SdlSound ( )
inlineoverride

Member Function Documentation

◆ getPosition() [1/2]

Vector3f SdlSound::getPosition ( ) const
inlineoverridevirtual

get the 3D position of the sound

Returns
Vector3f

Implements audio::ISound.

◆ getPosition() [2/2]

Vector3f SdlSound::getPosition ( ) const
inlineoverridevirtual

get the 3D position of the sound

Returns
Vector3f

Implements audio::ISound.

◆ getVelocity() [1/2]

Vector3f SdlSound::getVelocity ( ) const
inlineoverridevirtual

get the velocity of the sound

Returns
Vector3f

Implements audio::ISound.

◆ getVelocity() [2/2]

Vector3f SdlSound::getVelocity ( ) const
inlineoverridevirtual

get the velocity of the sound

Returns
Vector3f

Implements audio::ISound.

◆ getVolume() [1/2]

float SdlSound::getVolume ( ) const
inlineoverridevirtual

get the volume of the sound

Returns
float

Implements audio::ISound.

◆ getVolume() [2/2]

float SdlSound::getVolume ( ) const
inlineoverridevirtual

get the volume of the sound

Returns
float

Implements audio::ISound.

◆ isReady() [1/2]

bool SdlSound::isReady ( ) const
inlineoverridevirtual

Implements audio::ISound.

◆ isReady() [2/2]

bool SdlSound::isReady ( ) const
inlineoverridevirtual

Implements audio::ISound.

◆ pause() [1/2]

void SdlSound::pause ( )
inlineoverridevirtual

Suspends the sound without touching the position.

Does nothing if the sound is not playing. Idempotent.

Implements audio::ISound.

◆ pause() [2/2]

void SdlSound::pause ( )
inlineoverridevirtual

Suspends the sound without touching the position.

Does nothing if the sound is not playing. Idempotent.

Implements audio::ISound.

◆ play() [1/2]

void SdlSound::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.

◆ play() [2/2]

void SdlSound::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() [1/2]

void SdlSound::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.

◆ setPosition() [2/2]

void SdlSound::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() [1/2]

void SdlSound::setVelocity ( Vector3f velocity)
inlineoverridevirtual

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

Parameters
velocity

Implements audio::ISound.

◆ setVelocity() [2/2]

void SdlSound::setVelocity ( Vector3f velocity)
inlineoverridevirtual

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

Parameters
velocity

Implements audio::ISound.

◆ setVolume() [1/2]

void SdlSound::setVolume ( float volume)
inlineoverridevirtual

dans [0, 1] comme le contrat, MIX_MAX_VOLUME est un detail de SDL

Implements audio::ISound.

◆ setVolume() [2/2]

void SdlSound::setVolume ( float volume)
inlineoverridevirtual

dans [0, 1] comme le contrat ; MIX_SetTrackGain accepte au-dela

Implements audio::ISound.

◆ stop() [1/2]

void SdlSound::stop ( )
inlineoverridevirtual

Stops the sound AND rewinds to zero.

Does nothing if the sound is already stopped. Idempotent.

Implements audio::ISound.

◆ stop() [2/2]

void SdlSound::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 files: