#ifndef TINYSOUNDMIXER_HPP
#define TINYSOUNDMIXER_HPP

#define USE_SDFAT

#include <TinyScreen.h>
#ifdef USE_SDFAT
#include "SdFat.h"
#endif

class SoundMixer
{
public:
	enum
	{
		CHANNEL_COUNT = 4,
	};
	SoundMixer(void);
	~SoundMixer(void);
	void Append(int channel, const unsigned char* buffer, int size, bool loop);
	void Append(int channel, const char* path, bool loop);
	void Delete(int channel);
	void Read(unsigned char* buffer, int size);
	void Clear(void);
private:
	void MixBuffer(unsigned char* destination_buffer, const unsigned char* source_buffer, int size);
	bool use_sd_fat;
#ifdef USE_SDFAT
	SdFat sd_fat;
	SdFile* sd_file[CHANNEL_COUNT];
#endif
	const unsigned char* buffer[CHANNEL_COUNT];
	int size[CHANNEL_COUNT];
	int sample[CHANNEL_COUNT];
	bool loop[CHANNEL_COUNT];
	SoundMixer(SoundMixer&);
	SoundMixer& operator = (SoundMixer&);
};

#endif
