Exemple #1
0
int main(int argc, char *argv[])
{
	CoInitializeEx(nullptr, COINIT_MULTITHREADED);

	char *buffer = new char[BUFFER_SIZE];

	if (buffer == nullptr)
		return -11;

	try
	{
		audio.open(XAUDIO2_DEBUG_ENGINE);
		DMSG("open");
		Wav wav("D:\\openAL\\11k16bitpcm.wav");
		uint32_t readSize = wav.read(buffer, BUFFER_SIZE);
		DVAR(readSize);
		wav.close();
		DMSG("play");
		audio.play(wav.getFormat(), buffer, wav.getSize());

		while (audio.isPlaying())
			Thread::sleep(10);
	}
	catch (...)
	{
		std::cout << "error" << std::endl;
	}

	DMSG("close");
	audio.close();

	CoUninitialize();

	return 0;
}
Exemple #2
0
int main(int argc, char *argv[])
{
	CoInitializeEx(nullptr, COINIT_MULTITHREADED);

	try
	{
		audio.open(XAUDIO2_DEBUG_ENGINE);
		DMSG("open");
		Wav wav("D:\\openAL\\11k16bitpcm.wav");
		audio.stream(wav.getFormat());

		for (int i = 0; i < 2; ++i)
		{
			DMSG("submit buffer " << i);
			uint32_t size = wav.getSize();
			audio.appendBuffer(size);
			wav.read(audio.getBuffer(i), size);
			audio.submitBuffer(i, size);
		}

		wav.close();

		DMSG("sleep");
		Thread::sleep(10000);

		DMSG("stop");
		audio.stop();
	}
	catch (...)
	{
		std::cout << "error" << std::endl;
	}

	DMSG("close");
	audio.close();

	CoUninitialize();

	return 0;
}