#ifndef SOUNDERER_H_INCLUDED
#define SOUNDERER_H_INCLUDED

#include <iostream>
#include <string>
#include <map>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>

#define EXT_WAV 0
#define EXT_OGG 1
#define INFINITY_LOOP -1

class Sounderer
{
public:

    Sounderer();
    Sounderer(std::string folder);
    ~Sounderer();

    bool init();// à appeler avant utilisation

    bool preLoad(std::string nom, short extension = EXT_WAV);// Précharge le son pour accélerer sa premièrer lecture [!] Dossier et extension auto
    bool play(std::string nom, int repetition = 0);// Joue le son choisi, le charge automatiquement si pas encore chargé
    bool fadePlay(std::string nom, int crescendoLenght, int repetition = 0);// Démarre le son par un crescendo d'une longueur voulue
    bool stop(std::string nom);// Stoppe le son choisi
    void stopAll();
    void assignFolder(std::string folder);// Situe le dossier où sont contenus les sons

private:

    int m_lastCanal;
    std::string m_folder;

	std::map<std::string, int> m_channel;//Channel on which our sound is played
    std::map<std::string, Mix_Chunk*>::iterator m_it;
    std::map<std::string, Mix_Chunk*> m_paquet;

	int m_rate;// = 22050 : Frequency of audio playback
	Uint16 m_format;// = AUDIO_S16SYS : Format of the audio we're playing
	int m_nbChannels;// = 2 : 2 channels = stereo
	int m_bufferSize;// = 4096 : Size of the audio buffers in memory

};

#endif // SOUNDERER_H_INCLUDED