#ifndef _AUDIO_H
#define _AUDIO_H

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

#include		"output.h"
#include		"track.h"
#include		"manifest.h"
#include		"utils.h"

#include		"fmod.hpp"
#include		"fmod_errors.h"

#define WIN32_LEAN_AND_MEAN

class AudioManager
{
	private: 
	
		FMOD::System*			Audio; // The main FMOD audio system.
		FMOD::Channel*			Channel; // The FMOD channel of playing audio.

		OutputManager*			Output; // Link to output manager.

	public: 

		AudioManager();
		~AudioManager();

		std::vector<Track*>		Tracks; // List of tracks to play.
		Track*					ActiveTrack; // The currently playing track.

		AudioData				Data; // The audio data from the currently playing track.

		BOOL					Init(); // Initialise.
		VOID					Update(); // Update.
		VOID					Release(); // Release all object.
		BOOL					AddTrack(std::string path, bool stream); // Add a track to the list.
		BOOL					Play(); // Play the active track.
		BOOL					Play(Track* track); // Play a specific track.

		BOOL					Pause(); // Pause the active track.
		BOOL					Pause(Track* track); // Pause a specific track.

		VOID					Volume(float value); // Set volume.
		VOID					Pan(float value); // Set pan.

		BOOL					Next(); // Skip to next track in list.
		BOOL					Previous(); // Go back to previous track in list.
		BOOL					IsFinished(); // Checks active track has finished playing.
		BOOL					IsFinished(Track* track); // Checks if a specific track has finished playing.

		BOOL					Validate(FMOD_RESULT result); // Validates an FMOD result value.

		AudioData				GetData(); // Gets the audio data for visualisation.
		VOID					SetOutput(OutputManager* output); // Sets the output manager.
};

#endif


