예제 #1
0
Sound::Sound(Sounds id){
	FMOD_RESULT result;
	result = FMOD::System_Create(&fmodSystem);
	FmodErrorCheck(result);

    result = fmodSystem->init(32, FMOD_INIT_NORMAL, 0);
    FmodErrorCheck(result);

	this->id = id;
	switch(id){
	case Sounds::ROCKET_LAUCHED:
		result = fmodSystem->createSound("../data/sounds/launch_rocket.wav", FMOD_SOFTWARE, 0, &actionSound);
		FmodErrorCheck(result);
		break;
	case Sounds::MUSIC:
		result = fmodSystem->createStream("../data/sounds/music.mp3", FMOD_SOFTWARE , 0, &actionSound);
		FmodErrorCheck(result);

		break;
	case Sounds::MUSIC2:
		result = fmodSystem->createStream("../data/sounds/music2.mp3", FMOD_SOFTWARE , 0, &actionSound);
		FmodErrorCheck(result);

		break;
	case Sounds::MUSIC3:
		result = fmodSystem->createStream("../data/sounds/music3.mp3", FMOD_SOFTWARE, 0, &actionSound);
		FmodErrorCheck(result);

		break;
	case Sounds::MUSIC4:
		result = fmodSystem->createStream("../data/sounds/music4.mp3", FMOD_SOFTWARE, 0, &actionSound);
		FmodErrorCheck(result);

		break;
	case Sounds::MUSIC5:
		result = fmodSystem->createStream("../data/sounds/music5.mp3", FMOD_SOFTWARE, 0, &actionSound);
		FmodErrorCheck(result);

		break;
	case Sounds::MUSIC6:
		result = fmodSystem->createStream("../data/sounds/music6.mp3", FMOD_SOFTWARE, 0, &actionSound);
		FmodErrorCheck(result);

		break;


	case Sounds::EXPLOSION:
		result = fmodSystem->createSound("../data/sounds/explosion.wav", FMOD_SOFTWARE, 0, &actionSound);
		FmodErrorCheck(result);		
		break;


	}


	
}
예제 #2
0
// Play an event sound
bool CAudio::PlayEventSound()
{
	result = m_FmodSystem->playSound(m_eventSound, NULL, false, NULL);
	FmodErrorCheck(result);
	if (result != FMOD_OK)
		return false;
	return true;
}
예제 #3
0
bool CAudio::Initialise()
{
	// Create an FMOD system
	result = FMOD::System_Create(&m_FmodSystem);
	FmodErrorCheck(result);
	if (result != FMOD_OK) 
		return false;

	// Initialise the system
	result = m_FmodSystem->init(32, FMOD_INIT_NORMAL, 0);
	FmodErrorCheck(result);
	if (result != FMOD_OK) 
		return false;

	return true;
	
}
예제 #4
0
// Play a music stream
bool CAudio::PlayMusicStream()
{
	result = m_FmodSystem->playSound(m_music, NULL, false, &m_musicChannel);
	FmodErrorCheck(result);

	if (result != FMOD_OK)
		return false;
	return true;
}
예제 #5
0
	// trackManager serves as cache for sound clips
	void createSound(char *filePath, FMOD::Sound **sound)
	{
		if (trackManager.find(filePath) == trackManager.end()) {
			FmodErrorCheck(lowLevelSystem->createSound(filePath, FMOD_3D|FMOD_LOOP_NORMAL, 0, sound));
			trackManager.insert({ filePath, *sound });
		}
		else
			*sound = trackManager.find(filePath)->second;
	}
예제 #6
0
// Load an event sound
bool CAudio::LoadEventSound(char *filename)
{
	result = m_FmodSystem->createSound(filename, NULL, 0, &m_eventSound);
	FmodErrorCheck(result);
	if (result != FMOD_OK) 
		return false;

	return true;
	

}
예제 #7
0
// Load a music stream
bool CAudio::LoadMusicStream(char *filename)
{
	result = m_FmodSystem->createStream(filename, NULL | FMOD_LOOP_NORMAL, 0, &m_music);
	FmodErrorCheck(result);

	if (result != FMOD_OK) 
		return false;

	return true;
	

}
예제 #8
0
void Sound::Play(){
	FMOD_RESULT result;

	
	result = fmodSystem->playSound(FMOD_CHANNEL_FREE, actionSound, false, &channel );
	
	
	if (id==Sounds::ROCKET_LAUCHED){
		channel->setVolume(0.1f);
	}else if (id==Sounds::EXPLOSION){
		channel->setVolume(0.2f);
	} else if (id==Sounds::MUSIC || id==Sounds::MUSIC2 || id==Sounds::MUSIC3){
		//music_channel->setVolume(0.4);
	} else if (id==Sounds::MUSIC6){
		channel->setVolume(0.5);
	}
	FmodErrorCheck(result);
}
예제 #9
0
	bool init()
	{
		// init studio system
		FmodErrorCheck(FMOD::Studio::System::create(&system));
		
		// init lowlevel system
		FmodErrorCheck(system->getLowLevelSystem(&lowLevelSystem));

		int sampleRate = 0;
		FmodErrorCheck(lowLevelSystem->getSoftwareFormat(&sampleRate, NULL, NULL));
		unsigned int bufferSize = 0;
		FmodErrorCheck(lowLevelSystem->getDSPBufferSize(&bufferSize, NULL));
		FmodErrorCheck(lowLevelSystem->setSoftwareFormat(sampleRate, FMOD_SPEAKERMODE_SURROUND, 2)); // 3D

		FmodErrorCheck(system->initialize(1000, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED, NULL));

		// set distance units
		const float DISTANCEFACTOR = 1.0f;          // Units per meter.  I.e feet would = 3.28.  centimeters would = 100.
		lowLevelSystem->set3DSettings(1.0f, DISTANCEFACTOR, 1.0f);

		return true;
	}
예제 #10
0
	bool destroy()
	{
		FmodErrorCheck(lowLevelSystem->close());
		FmodErrorCheck(lowLevelSystem->release());
		return true;
	}
예제 #11
0
	bool update()
	{
		FmodErrorCheck(lowLevelSystem->update());
		return true;
	}
예제 #12
0
	void setListenerPosition(FMOD_VECTOR position, FMOD_VECTOR velocity, FMOD_VECTOR foward, FMOD_VECTOR up)
	{
		FmodErrorCheck(lowLevelSystem->set3DListenerAttributes(0, &position, &velocity, &foward, &up));
	}
예제 #13
0
	void setChannelPosition(FMOD_VECTOR position, FMOD_VECTOR velocity, FMOD::Channel *channel)
	{
		FmodErrorCheck(channel->set3DAttributes(&position, &velocity));
	}
예제 #14
0
	void playSound(FMOD::Sound *sound, FMOD::Channel **channel)
	{
		FmodErrorCheck(lowLevelSystem->playSound(sound, 0, false, channel));
	}