/*
File Name: Sound.h
Created By: Andy Odle
Date: Mar 14, 2010

Description: 
*/

#ifndef Sound_h
#define Sound_h

#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

#ifdef _WIN32
        // OpenAL include files.
        #include "C:/Program Files/OpenAL 1.1 SDK/include/al.h"
        #include "C:/Program Files/OpenAL 1.1 SDK\include/alc.h"
#else
        // OpenAL include files.
        #include "./AL/al.h"
        #include "./AL/alc.h"
#endif

#include "./source/inc/Thing.h"

#define WAV_BUFFER_SIZE 32768    // 32 KB buffers

class Sound : public Thing
{
    public:

        Sound();
        ~Sound();

        void Play();
        void Stop();
        void LoadWAVFile(const string &fileName_p, bool loopSound_p = false);

        float *GetSourcePosition(){return sourcePos_m;}
        float *GetSourceVelociety(){return sourceVel_m;}
        unsigned int GetSoundBuffer(){return wavBuffer_m;}

        void SetSoundSource(const unsigned int source_p){currentSource_m = source_p;}
        unsigned int GetSoundSource(){return currentSource_m;}

        // Required Thing interface.
        void Initialize();
        void Update();    
        void Draw();
        void Destory();

    private:

        unsigned short readByte16(const unsigned char buffer_p[2]);
        unsigned long readByte32(const unsigned char buffer_p[4]);

    private:
        
        float sourcePos_m[2];
        float sourceVel_m[2];

        unsigned int currentSource_m;
        unsigned int wavBuffer_m; 
};

#endif
