36 Mix_HaltChannel(_channel);
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);
91 void setVelocity(Vector3f velocity)
override { _velocity = velocity; }
97 return _channel >= 0 && Mix_GetChunk(_channel) == _buffer.
handle();
103 Vector3f _position{0, 0, 0};
104 Vector3f _velocity{0, 0, 0};
Un echantillon decode en memoire, partageable par plusieurs sons.
Definition SdlSoundBuffer.hpp:30
bool isReady() const override
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
SdlSound(SdlSoundBuffer &buffer)
Definition SdlSound.hpp:32
void setVelocity(Vector3f velocity) override
Definition SdlSound.hpp:91
Vector3f getPosition() const override
Definition SdlSound.hpp:89
~SdlSound() override
Definition SdlSound.hpp:34
void pause() override
Definition SdlSound.hpp:53
void stop() override
Definition SdlSound.hpp:58
bool isReady() const override
Definition SdlSound.hpp:39
Vector3f getVelocity() const override
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
Definition SdlSound.hpp:41
void setPosition(Vector3f position) override
Definition SdlSound.hpp:78
float getVolume() const override
Definition SdlSound.hpp:71