/**************************************************************
 *
 * sound.c source: methods for maxmod
 *
 **************************************************************/

#include "sound.h"

static mm_sound_effect build;
static mm_sound_effect win;
static mm_sound_effect wrong;

extern void soundInit()
{

	//consoleDemoInit();

	mmInitDefaultMem((mm_addr) soundbank_bin);

	// load the module
	mmLoad(MOD_FLATOUTLIES);
	mmSetModuleVolume(128);

	// load sound effects
	mmLoadEffect(SFX_BUILD);
	mmLoadEffect(SFX_WIN);
	mmLoadEffect(SFX_WRONG);

	// Start playing module
	mmStart(MOD_FLATOUTLIES, MM_PLAY_LOOP);

	build = (mm_sound_effect
)			{
				{	SFX_BUILD}, // id
			(int)(1.0f * (1<<10)), // rate
			0, // handle
			255, // volume
			128, // panning
		};

		win = (mm_sound_effect)
		{
			{	SFX_WIN}, // id
			(int)(1.0f * (1<<10)), // rate
			0, // handle
			255, // volume
			128, // panning
		};

		wrong = (mm_sound_effect)
		{
			{	SFX_WRONG}, // id
			(int)(1.0f * (1<<10)), // rate
			0, // handle
			255, // volume
			128, // panning
		};
	}

extern void playBuild()
{
	mmEffectEx(&build);
}

extern void playWin()
{
	mmEffectEx(&win);
}

extern void playWrong()
{
	mmEffectEx(&wrong);
}

extern void startLoop()
{
	mmStart(MOD_FLATOUTLIES, MM_PLAY_LOOP);
}

extern void stopLoop()
{
	mmStop();
}
