#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

    // Fonctions de bruitage
    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();

    // Fonctions de musique
    bool startMusic(std::string musicName = "");

    // Fonction param
    void assignFolder(std::string folder);// Situe le dossier o� sont contenus les sons

private:

    int m_lastCanal;
    std::string m_folder;

    std::string m_musicName;
    Mix_Music* m_music;

	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