36 Mix_HaltChannel(_channel);
39 bool isReady()
const override {
return _buffer.isReady(); }
42 if (!_buffer.isReady())
44 if (mine() && Mix_Paused(_channel)) {
48 _channel = Mix_PlayChannel(-1, _buffer.handle(), 0);
50 Mix_Volume(_channel,
static_cast<int>(_volume * MIX_MAX_VOLUME));
60 Mix_HaltChannel(_channel);
68 Mix_Volume(_channel,
static_cast<int>(volume * MIX_MAX_VOLUME));
71 float getVolume()
const override {
return _volume; }
83 const float clamped = (position.
x < -1.f) ? -1.f : (position.
x > 1.f ? 1.f : position.
x);
84 const uint8_t right =
static_cast<uint8_t
>((clamped + 1.f) * 0.5f * 255.f);
86 Mix_SetPanning(_channel,
static_cast<uint8_t
>(255 - right), right);
97 return _channel >= 0 && Mix_GetChunk(_channel) == _buffer.
handle();
100 SdlSoundBuffer &_buffer;
Un echantillon decode en memoire, partageable par plusieurs sons.
Definition SdlSoundBuffer.hpp:30
Mix_Chunk * handle() const
Definition SdlSoundBuffer.hpp:69
SdlSound(SdlSoundBuffer &buffer)
Definition SdlSound.hpp:32
void setVelocity(Vector3f velocity) override
set the velocity of the sound, used by backends that apply a doppler effect
Definition SdlSound.hpp:91
Vector3f getPosition() const override
get the 3D position of the sound
Definition SdlSound.hpp:89
~SdlSound() override
Definition SdlSound.hpp:34
void pause() override
Suspends the sound without touching the position.
Definition SdlSound.hpp:53
void stop() override
Stops the sound AND rewinds to zero.
Definition SdlSound.hpp:58
bool isReady() const override
Definition SdlSound.hpp:39
Vector3f getVelocity() const override
get the velocity of the sound
Definition SdlSound.hpp:92
void setVolume(float volume) override
dans [0, 1] comme le contrat, MIX_MAX_VOLUME est un detail de SDL
Definition SdlSound.hpp:65
void play() override
Fires the sound from the beginning.
Definition SdlSound.hpp:41
void setPosition(Vector3f position) override
set the 3D position of the sound, for backends that spatialize against a listener....
Definition SdlSound.hpp:78
float getVolume() const override
get the volume of the sound
Definition SdlSound.hpp:71
Vector3< double > Vector3f
Definition Vector3.hpp:121
T x
Definition Vector3.hpp:21