示例#1
0
void FmodAudioPlayer::close()
{
    FMOD_RESULT result;

    //BGM
    if (pBGMChannel != NULL)
    {
        result = pBGMChannel->stop();
        ERRCHECKWITHEXIT(result);
        pBGMChannel = 0;
    }

    if (pMusic != NULL)
    {
        result = pMusic->release();
        ERRCHECKWITHEXIT(result);
        pMusic = 0;
    }

    result = pChannelGroup->release();
    ERRCHECKWITHEXIT(result);
    sMusicPath.clear();

    result = pSystem->close();
    ERRCHECKWITHEXIT(result);
    result = pSystem->release();
    ERRCHECKWITHEXIT(result);

    init();
}
示例#2
0
FmodAudioPlayer::~FmodAudioPlayer()
{
    FMOD_RESULT result;

    //BGM
    if (pBGMChannel != NULL)
    {
        result = pBGMChannel->stop();
        ERRCHECKWITHEXIT(result);
    }

    if (pMusic != NULL)
    {
        result = pMusic->release();
        ERRCHECKWITHEXIT(result);
    }

    result = pChannelGroup->release();
    ERRCHECKWITHEXIT(result);

    result = pSystem->close();
    ERRCHECKWITHEXIT(result);
    result = pSystem->release();
    ERRCHECKWITHEXIT(result);
}
示例#3
0
void FmodAudioPlayer::stopBackgroundMusic(bool bReleaseData)
{
    FMOD_RESULT result;

    pSystem->update();

    if ((pBGMChannel == NULL) || (pMusic == NULL))
    {
        return;
    }
    if (bReleaseData)
    {
        result = pBGMChannel->stop();
        ERRCHECKWITHEXIT(result);
        result = pMusic->release();
        ERRCHECKWITHEXIT(result);
        pBGMChannel = 0;
        pMusic      = 0;
    }
    else
    {
        result = pBGMChannel->stop();
        ERRCHECKWITHEXIT(result);
        pBGMChannel = 0;
    }
    sMusicPath.clear();
}
示例#4
0
// for sound effects
float FmodAudioPlayer::getEffectsVolume() {
	float fVolumn;
	pSystem->update();
	FMOD_RESULT result = pChannelGroup->getVolume(&fVolumn);
	ERRCHECKWITHEXIT(result);
	return fVolumn;
}
示例#5
0
void FmodAudioPlayer::rewindBackgroundMusic() {
	if (pBGMChannel == NULL) {
		return;
	}
	pSystem->update();
	FMOD_RESULT result = pBGMChannel->setPosition(0, FMOD_TIMEUNIT_MS);
	ERRCHECKWITHEXIT(result);
}
示例#6
0
void FmodAudioPlayer::resumeBackgroundMusic() {
	if (pBGMChannel == NULL) {
		return;
	}
	pSystem->update();
	FMOD_RESULT result = pBGMChannel->setPaused(false);
	ERRCHECKWITHEXIT(result);
}
示例#7
0
void FmodAudioPlayer::setBackgroundMusicVolume(float volume) {
	if (pBGMChannel == NULL) {
		return;
	}
	pSystem->update();
	FMOD_RESULT result = pBGMChannel->setVolume(volume);
	ERRCHECKWITHEXIT(result);

}
示例#8
0
float FmodAudioPlayer::getBackgroundMusicVolume() {
	float fVolumn;
	if (pBGMChannel == NULL) {
		return 0;
	}
	pSystem->update();
	FMOD_RESULT result = pBGMChannel->getVolume(&fVolumn);
	ERRCHECKWITHEXIT(result);
	return fVolumn;
}
示例#9
0
bool FmodAudioPlayer::isBackgroundMusicPlaying() {
	bool bPlaying;
	if (pBGMChannel == NULL) {
		return false;
	}
	pSystem->update();
	FMOD_RESULT result = pBGMChannel->isPlaying(&bPlaying);
	ERRCHECKWITHEXIT(result);
	return bPlaying;

}
示例#10
0
void FmodAudioPlayer::init()
{
    //init
    FMOD_RESULT        result;
    FMOD::ChannelGroup *masterChannelGroup;

    unsigned int version;

    /*
     * Create a System object and initialize.
     */
    result = FMOD::System_Create(&pSystem);
    ERRCHECKWITHEXIT(result);

    result = pSystem->setOutput(FMOD_OUTPUTTYPE_ALSA);
    ERRCHECKWITHEXIT(result);

    result = pSystem->init(32, FMOD_INIT_NORMAL, 0);
    ERRCHECKWITHEXIT(result);

    result = pSystem->createChannelGroup("Channel Group", &pChannelGroup);
    ERRCHECKWITHEXIT(result);

    result = pSystem->getMasterChannelGroup(&masterChannelGroup);
    ERRCHECKWITHEXIT(result);

    result = masterChannelGroup->addGroup(pChannelGroup);
    ERRCHECKWITHEXIT(result);

    mapEffectSound.clear();
}
示例#11
0
// BGM
void FmodAudioPlayer::preloadBackgroundMusic(const char* pszFilePath) {
	FMOD_RESULT result;
	pSystem->update();
	string sNewMusicPath = string(pszFilePath) + szMusicSuffix;
	if (pMusic && sNewMusicPath != sMusicPath) {
		//release old
		result = pMusic->release();
		ERRCHECKWITHEXIT(result);

		sMusicPath = sNewMusicPath;

	}

	result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, &pMusic);
	ERRCHECK(result);
}
示例#12
0
void FmodAudioPlayer::setEffectsVolume(float volume)
{
    pSystem->update();
    FMOD_RESULT result = pChannelGroup->setVolume(volume);
    ERRCHECKWITHEXIT(result);
}