Exemple #1
0
int main()
{
	AudioDevice *device = new AudioDevice();

	IMusic *music = device->CreateMusic();
	if (!music->LoadFromFile("music1.wav"))
	{
		printf("Failed to load sound file!");
	}
	
	IMusic *music2 = device->CreateMusic();
	if (!music2->LoadFromFile("music2.wav"))
	{

	}
	float seconds = 0;
	while (true)
	{
		char c = getchar();

		if (c == 'r')
		{
			music->Rewind();
			printf("Rewind\n");
		}
		if (c == 's')
		{
			music->Stop();
			printf("Stop\n");
		}
		if (c == 'l')
		{
			music->SetLooping(!music->IsLooping());
			printf("SetLooping: %d\n", music->IsLooping());
		}
		if (c == 'p')
		{
			if (!music->IsPlaying())
			{
				music->Play();
				music2->Play();
				printf("Play\n");
			}
			else{
				music->Pause();
				music2->Pause();
				printf("Pause\n");
			}
		}
		device->IsError();
	}
	return 0;
}
Exemple #2
0
int main()
{
	AudioDevice *device = new AudioDevice();

	ISound *wave1 = device->CreateSound();
	ISound *wave2 = device->CreateSound();
	ISound *wave3 = device->CreateSound();

	if (!wave1->LoadFromFile("wave1.wav"))
	{
		printf("Failed to load sound file!");
	}
	if (!wave2->LoadFromFile("wave2.wav"))
	{
		printf("Failed to load sound file!");
	}
	if (!wave3->LoadFromFile("wave3.wav"))
	{
		printf("Failed to load sound file!");
	}


	IListener *listener = device->GetListener();
	wave1->SetLooping(true);
	wave1->SetLocation(-1.0, 1.0, 1);
	wave1->Play();

	wave2->SetLooping(true);
	wave2->SetLocation(0, 1, 1);
	wave2->Play();

	wave3->SetLooping(true);
	wave3->SetLocation(-1, 0, 1);
	wave3->Play();

	float x = 0;
	float y = 0;
	while (true)
	{
		char c = getchar();
		if (c == 'w')
		{
			y += 0.1f;
			printf("%f, %f\n", x, y);
		}
		if (c == 's')
		{
			y -= 0.1f;
			printf("%f, %f\n", x, y);

		}
		if (c == 'a')
		{
			x += 0.1f;
			printf("%f, %f\n", x, y);
		}

		if (c == 'd')
		{
			x -= 0.1f;
			printf("%f, %f\n", x, y);
		}

		listener->SetLocation(x, y, 1);
		device->IsError();
	}
}