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

Un flux long, decode au fil de la lecture. More...

#include <SdlMusic.hpp>

Inheritance diagram for SdlMusic:
Collaboration diagram for SdlMusic:

Public Member Functions

 SdlMusic (std::string path)
 ~SdlMusic () override
bool isReady () const override
void play () override
 Starts playback.
void pause () override
 Suspends playback without touching the position.
void stop () override
 Stops playback AND rewinds to zero.
void update () override
 SDL_mixer decode sur son propre fil : rien a pousser par frame.
void setVolume (float volume) override
 set the volume of the music
float getVolume () const override
 get the volume of the music
void setLoop (bool loop) override
 set the music to loop or not
bool getLoop () const override
 get if the music is looping or not
void setTime (float position) override
 Set the time of the music in seconds.
float getTime () const override
 Get the current time of the music in seconds.
float getLength () const override
 Get the Length of the music.
void setPosition (Vector3f position) override
 set the 3D position of the music, 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 usable music, unlike a fake 3D model with nothing to render.
Vector3f getPosition () const override
 get the 3D position of the music
void setVelocity (Vector3f velocity) override
 set the velocity of the music, used by backends that apply a doppler effect
Vector3f getVelocity () const override
 get the velocity of the music
 SdlMusic (MIX_Mixer *mixer, std::string path)
 ~SdlMusic () override
bool isReady () const override
void play () override
 Starts playback.
void pause () override
 Suspends playback without touching the position.
void stop () override
 Stops playback AND rewinds to zero.
void update () override
 SDL_mixer decode sur son propre fil : rien a pousser par frame.
void setVolume (float volume) override
 set the volume of the music
float getVolume () const override
 get the volume of the music
void setLoop (bool loop) override
 set the music to loop or not
bool getLoop () const override
 get if the music is looping or not
void setTime (float position) override
 Set the time of the music in seconds.
float getTime () const override
 la vraie position de lecture, que SDL2 ne savait pas donner
float getLength () const override
 Get the Length of the music.
void setPosition (Vector3f position) override
 set the 3D position of the music, 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 usable music, unlike a fake 3D model with nothing to render.
Vector3f getPosition () const override
 get the 3D position of the music
void setVelocity (Vector3f velocity) override
 set the velocity of the music, used by backends that apply a doppler effect
Vector3f getVelocity () const override
 get the velocity of the music
Public Member Functions inherited from audio::IMusic
virtual ~IMusic ()=default

Detailed Description

Un flux long, decode au fil de la lecture.

Un flux long, decode au fil de la lecture, sur sa propre piste.

SDL_mixer n'a qu'UN canal de musique pour tout le processus : deux SdlMusic existent tres bien cote a cote, mais la seconde a jouer remplace la premiere. Chaque objet verifie donc que le canal est encore le sien avant d'agir, sinon un stop() sur une musique arretee depuis longtemps couperait celle qui joue.

SDL3_mixer n'a plus de canal musique unique : une musique est une piste comme une autre, avec le tampon charge en flux plutot qu'en entier. Deux musiques peuvent donc jouer ensemble, ce que SDL2 rendait impossible - et plus besoin de verifier avant chaque ordre que le canal est encore le notre.

predecode = false : le fichier est lu au fur et a mesure, ce qui evite de mettre plusieurs minutes d'audio en memoire.

Constructor & Destructor Documentation

◆ SdlMusic() [1/2]

SdlMusic::SdlMusic ( std::string path)
inline

◆ ~SdlMusic() [1/2]

SdlMusic::~SdlMusic ( )
inlineoverride

◆ SdlMusic() [2/2]

SdlMusic::SdlMusic ( MIX_Mixer * mixer,
std::string path )
inline

◆ ~SdlMusic() [2/2]

SdlMusic::~SdlMusic ( )
inlineoverride

Member Function Documentation

◆ getLength() [1/2]

float SdlMusic::getLength ( ) const
inlineoverridevirtual

Get the Length of the music.

Returns
float

Implements audio::IMusic.

◆ getLength() [2/2]

float SdlMusic::getLength ( ) const
inlineoverridevirtual

Get the Length of the music.

Returns
float

Implements audio::IMusic.

◆ getLoop() [1/2]

bool SdlMusic::getLoop ( ) const
inlineoverridevirtual

get if the music is looping or not

Returns
true
false

Implements audio::IMusic.

◆ getLoop() [2/2]

bool SdlMusic::getLoop ( ) const
inlineoverridevirtual

get if the music is looping or not

Returns
true
false

Implements audio::IMusic.

◆ getPosition() [1/2]

Vector3f SdlMusic::getPosition ( ) const
inlineoverridevirtual

get the 3D position of the music

Returns
Vector3f

Implements audio::IMusic.

◆ getPosition() [2/2]

Vector3f SdlMusic::getPosition ( ) const
inlineoverridevirtual

get the 3D position of the music

Returns
Vector3f

Implements audio::IMusic.

◆ getTime() [1/2]

float SdlMusic::getTime ( ) const
inlineoverridevirtual

Get the current time of the music in seconds.

Returns
float

Implements audio::IMusic.

◆ getTime() [2/2]

float SdlMusic::getTime ( ) const
inlineoverridevirtual

la vraie position de lecture, que SDL2 ne savait pas donner

Implements audio::IMusic.

◆ getVelocity() [1/2]

Vector3f SdlMusic::getVelocity ( ) const
inlineoverridevirtual

get the velocity of the music

Returns
Vector3f

Implements audio::IMusic.

◆ getVelocity() [2/2]

Vector3f SdlMusic::getVelocity ( ) const
inlineoverridevirtual

get the velocity of the music

Returns
Vector3f

Implements audio::IMusic.

◆ getVolume() [1/2]

float SdlMusic::getVolume ( ) const
inlineoverridevirtual

get the volume of the music

Returns
float

Implements audio::IMusic.

◆ getVolume() [2/2]

float SdlMusic::getVolume ( ) const
inlineoverridevirtual

get the volume of the music

Returns
float

Implements audio::IMusic.

◆ isReady() [1/2]

bool SdlMusic::isReady ( ) const
inlineoverridevirtual

Implements audio::IMusic.

◆ isReady() [2/2]

bool SdlMusic::isReady ( ) const
inlineoverridevirtual

Implements audio::IMusic.

◆ pause() [1/2]

void SdlMusic::pause ( )
inlineoverridevirtual

Suspends playback without touching the position.

Does nothing if the stream is not playing. Idempotent.

Implements audio::IMusic.

◆ pause() [2/2]

void SdlMusic::pause ( )
inlineoverridevirtual

Suspends playback without touching the position.

Does nothing if the stream is not playing. Idempotent.

Implements audio::IMusic.

◆ play() [1/2]

void SdlMusic::play ( )
inlineoverridevirtual

Starts playback.

Three states, and every action does ONLY what it says :

stopped --play()--> playing  --pause()--> paused
paused  --play()--> playing  (resumes where it was)
stopped --play()--> playing  (from zero)

play() on a stream that is already playing DOES NOTHING. It does not restart from the beginning : without that rule, a play() called every frame stutters on one vendor and plays normally on the other. To restart, call stop() then play(), or setTime(0) - explicitly.

Implements audio::IMusic.

◆ play() [2/2]

void SdlMusic::play ( )
inlineoverridevirtual

Starts playback.

Three states, and every action does ONLY what it says :

stopped --play()--> playing  --pause()--> paused
paused  --play()--> playing  (resumes where it was)
stopped --play()--> playing  (from zero)

play() on a stream that is already playing DOES NOTHING. It does not restart from the beginning : without that rule, a play() called every frame stutters on one vendor and plays normally on the other. To restart, call stop() then play(), or setTime(0) - explicitly.

Implements audio::IMusic.

◆ setLoop() [1/2]

void SdlMusic::setLoop ( bool loop)
inlineoverridevirtual

set the music to loop or not

Parameters
loop

Implements audio::IMusic.

◆ setLoop() [2/2]

void SdlMusic::setLoop ( bool loop)
inlineoverridevirtual

set the music to loop or not

Parameters
loop

Implements audio::IMusic.

◆ setPosition() [1/2]

void SdlMusic::setPosition ( Vector3f position)
inlineoverridevirtual

set the 3D position of the music, 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 usable music, unlike a fake 3D model with nothing to render.

Parameters
position

Implements audio::IMusic.

◆ setPosition() [2/2]

void SdlMusic::setPosition ( Vector3f position)
inlineoverridevirtual

set the 3D position of the music, 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 usable music, unlike a fake 3D model with nothing to render.

Parameters
position

Implements audio::IMusic.

◆ setTime() [1/2]

void SdlMusic::setTime ( float position)
inlineoverridevirtual

Set the time of the music in seconds.

The position is CLAMPED to [0, getLength()] : asking past the end stops at the end, a negative value rewinds to zero. Without that rule each vendor improvises - raylib wrapped around (115s on a 109s track gave 6s) where sfml fell to 0.

Parameters
position

Implements audio::IMusic.

◆ setTime() [2/2]

void SdlMusic::setTime ( float position)
inlineoverridevirtual

Set the time of the music in seconds.

The position is CLAMPED to [0, getLength()] : asking past the end stops at the end, a negative value rewinds to zero. Without that rule each vendor improvises - raylib wrapped around (115s on a 109s track gave 6s) where sfml fell to 0.

Parameters
position

Implements audio::IMusic.

◆ setVelocity() [1/2]

void SdlMusic::setVelocity ( Vector3f velocity)
inlineoverridevirtual

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

Parameters
velocity

Implements audio::IMusic.

◆ setVelocity() [2/2]

void SdlMusic::setVelocity ( Vector3f velocity)
inlineoverridevirtual

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

Parameters
velocity

Implements audio::IMusic.

◆ setVolume() [1/2]

void SdlMusic::setVolume ( float volume)
inlineoverridevirtual

set the volume of the music

Parameters
volume

Implements audio::IMusic.

◆ setVolume() [2/2]

void SdlMusic::setVolume ( float volume)
inlineoverridevirtual

set the volume of the music

Parameters
volume

Implements audio::IMusic.

◆ stop() [1/2]

void SdlMusic::stop ( )
inlineoverridevirtual

Stops playback AND rewinds to zero.

Does nothing if the stream is already stopped. Idempotent.

Implements audio::IMusic.

◆ stop() [2/2]

void SdlMusic::stop ( )
inlineoverridevirtual

Stops playback AND rewinds to zero.

Does nothing if the stream is already stopped. Idempotent.

Implements audio::IMusic.

◆ update() [1/2]

void SdlMusic::update ( )
inlineoverridevirtual

SDL_mixer decode sur son propre fil : rien a pousser par frame.

Implements audio::IMusic.

◆ update() [2/2]

void SdlMusic::update ( )
inlineoverridevirtual

SDL_mixer decode sur son propre fil : rien a pousser par frame.

Implements audio::IMusic.


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