16#include <SDL3_mixer/SDL_mixer.h>
36 _track = MIX_CreateTrack(mixer);
38 MIX_SetTrackAudio(_track, buffer.
handle());
43 MIX_DestroyTrack(_track);
46 bool isReady()
const override {
return _track !=
nullptr && _buffer.isReady(); }
51 if (MIX_TrackPaused(_track)) {
52 MIX_ResumeTrack(_track);
55 MIX_PlayTrack(_track, 0);
60 MIX_PauseTrack(_track);
65 MIX_StopTrack(_track, 0);
72 MIX_SetTrackGain(_track, volume);
75 float getVolume()
const override {
return _volume; }
85 const MIX_Point3D point{
static_cast<float>(position.
x),
86 static_cast<float>(position.
y),
87 static_cast<float>(position.
z)};
89 MIX_SetTrack3DPosition(_track, &point);
100 MIX_Track *_track =
nullptr;
Un echantillon decode en memoire, partageable par plusieurs sons.
Definition SdlSoundBuffer.hpp:30
bool isReady() const override
notice if the buffer is ready
Definition SdlSoundBuffer.hpp:44
Mix_Chunk * handle() const
Definition SdlSoundBuffer.hpp:69
Une lecture d'un tampon, sur son propre canal.
Definition SdlSound.hpp:29
void setVelocity(Vector3f velocity) override
set the velocity of the sound, used by backends that apply a doppler effect
Definition SdlSound.hpp:95
Vector3f getPosition() const override
get the 3D position of the sound
Definition SdlSound.hpp:92
~SdlSound() override
Definition SdlSound.hpp:41
void pause() override
Suspends the sound without touching the position.
Definition SdlSound.hpp:58
void stop() override
Stops the sound AND rewinds to zero.
Definition SdlSound.hpp:63
bool isReady() const override
Definition SdlSound.hpp:46
Vector3f getVelocity() const override
get the velocity of the sound
Definition SdlSound.hpp:96
SdlSound(MIX_Mixer *mixer, SdlSoundBuffer &buffer)
Definition SdlSound.hpp:35
void setVolume(float volume) override
dans [0, 1] comme le contrat ; MIX_SetTrackGain accepte au-dela
Definition SdlSound.hpp:69
void play() override
Fires the sound from the beginning.
Definition SdlSound.hpp:48
void setPosition(Vector3f position) override
set the 3D position of the sound, for backends that spatialize against a listener....
Definition SdlSound.hpp:80
float getVolume() const override
get the volume of the sound
Definition SdlSound.hpp:75
Vector3< double > Vector3f
Definition Vector3.hpp:121
T x
Definition Vector3.hpp:21
T y
Definition Vector3.hpp:21
T z
Definition Vector3.hpp:21