11#ifndef SDLSOUNDBUFFER_HPP_
12#define SDLSOUNDBUFFER_HPP_
18#include "ISoundBuffer.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;
Un echantillon decode en memoire, partageable par plusieurs sons.
Definition SdlSoundBuffer.hpp:30
~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
Definition SdlSoundBuffer.hpp:44
Mix_Chunk * handle() const
Definition SdlSoundBuffer.hpp:69