bool SoundManager::Init(HWND hwnd) {
	bool result;
	/*
		First init the DirectSound API as well as the primary buffer.
		Then LoadWaveFile can be called which will load in the .wav audio file and init the secondary buffer with the audio info.
		After loading is complete then PlayWaveFile is called which then plays the .wav file once.
	*/

	// Init direct sound and the primary buffer
	result = InitDirectSound(hwnd);
	if (!result) {
		return false;
	}
	
	
	// Load the background music
	result = LoadWaveFile("Sound\\ElectroSong.wav", &mBGMusic1Buffer);
	if (!result) {
		return false;
	}
	

	// Load a wave audio file onto a secondary buffer
	result = LoadWaveFile("Sound\\quack.wav", &mSecondBuffer);
	if (!result) {
		return false;
	}

	return true;
}
示例#2
0
ALERROR CSoundMgr::LoadWaveFromBuffer (IReadBlock &Data, int *retiChannel)

//	LoadWaveFromBuffer
//
//	Loads a wave file from a buffer

	{
	ALERROR error;
	HMMIO hFile;
	MMIOINFO info;

	if (m_pDS == NULL)
		{
		*retiChannel = 0;
		return NOERROR;
		}

	::ZeroMemory(&info, sizeof(info));
	info.pchBuffer = Data.GetPointer(0, -1);
	info.fccIOProc = FOURCC_MEM;
	info.cchBuffer = Data.GetLength();

	hFile = mmioOpen(NULL, &info, MMIO_READ);
	if (hFile == NULL)
		return ERR_FAIL;

	if (error = LoadWaveFile(hFile, retiChannel))
		return error;

	return NOERROR;
	}
示例#3
0
ALERROR CSoundMgr::LoadWaveFile (const CString &sFilename, int *retiChannel)

//	LoadWaveFile
//
//	Creates a sound buffer from a WAV file

	{
	ALERROR error;
	HMMIO hFile;

	if (m_pDS == NULL)
		{
		*retiChannel = 0;
		return NOERROR;
		}

	hFile = mmioOpen(sFilename.GetASCIIZPointer(), NULL, MMIO_READ | MMIO_ALLOCBUF);
	if (hFile == NULL)
		return ERR_FAIL;

	if (error = LoadWaveFile(hFile, retiChannel))
		return error;

	SChannel *pChannel = GetChannel(*retiChannel);
	pChannel->sFilename = sFilename;
	return NOERROR;
	}
示例#4
0
bool SoundClass::Initialize(HWND hwnd)
{
	bool result;

	// Initialize direct sound and the primary sound buffer.
	result = InitializeDirectSound(hwnd);
	if (!result)
	{
		return false;
	}

	// Load a wave audio file onto a secondary buffer.
	result = LoadWaveFile("../Engine/data/sound02.wav", &m_secondaryBuffer1, &m_secondary3DBuffer1);
	if (!result)
	{
		return false;
	}

	// Play the wave file now that it has been loaded.
	result = PlayWaveFile();
	if (!result)
	{
		return false;
	}


	return true;
}
示例#5
0
bool SoundClass::Initialize(HWND hwnd, char * _filename, int volume, bool loop)
{
	bool result;


	// Initialize direct sound and the primary sound buffer.
	result = InitializeDirectSound(hwnd);
	if (!result)
	{
		return false;
	}

	// Load a wave audio file onto a secondary buffer.
	result = LoadWaveFile(_filename, &m_secondaryBuffer1);
	if (!result)
	{
		return false;
	}

	// Play the wave file now that it has been loaded.
	result = PlayWaveFile( volume,  loop);
	if (!result)
	{
		return false;
	}

	return true;
}
示例#6
0
bool SoundClass::Initialize(HWND hwnd, char * _filename, int volume, bool loop)
{
	bool result;


	result = InitializeDirectSound(hwnd);
	if (!result)
	{
		return false;
	}
	
	result = LoadWaveFile(_filename, &m_secondaryBuffer1);
	if (!result)
	{
		return false;
	}

	result = PlayWaveFile( volume,  loop);
	if (!result)
	{
		return false;
	}

	return true;
}
示例#7
0
bool SoundClass::Initialize(HWND hwnd)
{
	bool result;
	// Initialize direct sound and the primary sound buffer.
	result = InitializeDirectSound(hwnd);
	if(!result)
	{
		return false;
	}

	// Load a wave audio file onto a secondary buffer.
	result = LoadWaveFile(FileSystemHelper::GetResourcePath(L"/Sound/sound01.wav"), &m_secondaryBuffer1);
	if(!result)
	{
		return false;
	}

	// Play the wave file now that it has been loaded.
	result = PlayWaveFile();
	if(!result)
	{
		return false;
	}

	return true;
}
示例#8
0
bool SoundClass::Initialize(HWND hwnd)
{
	bool result;

	result = InitializeDirectSound(hwnd);
	if (!result)
	{
		return false;
	}

	result = LoadWaveFile("./Sound/f1.wav", &_secondaryBuffer1);
	if (!result)
	{
		return false;
	}

	std::string file1 = "catapult_w.wav";

	std::string path = "./Sound/";

	_waveBuffers[file1] = NULL;

	result = LoadWaveFile((path + file1).c_str(), &_waveBuffers[file1]);
	if (!result)
	{
		return false;
	}
	//result = LoadWaveFile()

	result = PlayWaveFile();
	if (!result)
	{
		return false;
	}

	return true;
}
示例#9
0
bool Sound::Init(HWND hWnd, char *soundFile)
{
    bool result ;
    result = InitDirectSound(hWnd);
    if (!result)
    {
        return false;
    }

    //Load a wave audio file
    result = LoadWaveFile(soundFile, &pSecondaryBuffer);
    if (!result)
    {
        return false;
    }

    return true;
}
示例#10
0
bool Sound::Initialize(const char* filename, HWND hwnd, int volume)
{
	bool result;

	m_volume = volume;

	result = InitializeDirectSound(hwnd);
	if(!result)
	{
		return false;
	}

	result = LoadWaveFile(filename, &m_secondaryBuffer1);
	if(!result)
	{
		return false;
	}

	return true;
}