11#ifndef SDLSOUNDBUFFER_HPP_
12#define SDLSOUNDBUFFER_HPP_
34 _chunk = Mix_LoadWAV(path.c_str());
36 std::cerr <<
"Failed to load sound: " << Mix_GetError() << std::endl;
41 Mix_FreeChunk(_chunk);
44 bool isReady()
const override {
return _chunk !=
nullptr; }
59 if (!_chunk || !Mix_QuerySpec(&frequency, &format, &channels) || frequency == 0)
62 const int bytes = (SDL_AUDIO_BITSIZE(format) / 8) * channels;
66 return static_cast<float>(_chunk->alen) /
static_cast<float>(bytes * frequency);
69 Mix_Chunk *
handle()
const {
return _chunk; }
72 Mix_Chunk *_chunk =
nullptr;
~SdlSoundBuffer()
Definition SdlSoundBuffer.hpp:39
float getLength() const override
La duree, en secondes.
Definition SdlSoundBuffer.hpp:54
SdlSoundBuffer(std::string path)
Definition SdlSoundBuffer.hpp:33
bool isReady() const override
notice if the buffer is ready
Definition SdlSoundBuffer.hpp:44
Mix_Chunk * handle() const
Definition SdlSoundBuffer.hpp:69
Loaded audio samples, independent of any ISound that plays them - deleting every ISound built from a ...
Definition ISoundBuffer.hpp:24