axmol/CocosDenshion/linux/SimpleAudioEngineFMOD.cpp

142 lines
4.1 KiB
C++
Raw Normal View History

2013-07-05 16:28:06 +08:00
#ifndef OPENAL
2012-08-02 13:02:59 +08:00
#include "SimpleAudioEngine.h"
#include "FmodAudioPlayer.h"
#include "cocos2d.h"
USING_NS_CC;
2012-08-02 13:02:59 +08:00
namespace CocosDenshion {
static AudioPlayer* oAudioPlayer;
SimpleAudioEngine::SimpleAudioEngine() {
oAudioPlayer = FmodAudioPlayer::sharedPlayer();
}
SimpleAudioEngine::~SimpleAudioEngine() {
}
SimpleAudioEngine* SimpleAudioEngine::getInstance() {
2012-08-02 13:02:59 +08:00
static SimpleAudioEngine s_SharedEngine;
return &s_SharedEngine;
}
void SimpleAudioEngine::end() {
oAudioPlayer->close();
}
//////////////////////////////////////////////////////////////////////////
// BackgroundMusic
//////////////////////////////////////////////////////////////////////////
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath,
bool bLoop) {
// Changing file path to full path
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
oAudioPlayer->playBackgroundMusic(fullPath.c_str(), bLoop);
2012-08-02 13:02:59 +08:00
}
void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) {
oAudioPlayer->stopBackgroundMusic(bReleaseData);
}
void SimpleAudioEngine::pauseBackgroundMusic() {
oAudioPlayer->pauseBackgroundMusic();
}
void SimpleAudioEngine::resumeBackgroundMusic() {
oAudioPlayer->resumeBackgroundMusic();
}
void SimpleAudioEngine::rewindBackgroundMusic() {
oAudioPlayer->rewindBackgroundMusic();
}
bool SimpleAudioEngine::willPlayBackgroundMusic() {
return oAudioPlayer->willPlayBackgroundMusic();
}
bool SimpleAudioEngine::isBackgroundMusicPlaying() {
return oAudioPlayer->isBackgroundMusicPlaying();
}
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) {
// Changing file path to full path
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return oAudioPlayer->preloadBackgroundMusic(fullPath.c_str());
2012-08-02 13:02:59 +08:00
}
//////////////////////////////////////////////////////////////////////////
// effect function
//////////////////////////////////////////////////////////////////////////
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
float pitch, float pan, float gain) {
// Changing file path to full path
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return oAudioPlayer->playEffect(fullPath.c_str(), bLoop, pitch, pan, gain);
2012-08-02 13:02:59 +08:00
}
void SimpleAudioEngine::stopEffect(unsigned int nSoundId) {
return oAudioPlayer->stopEffect(nSoundId);
}
void SimpleAudioEngine::preloadEffect(const char* pszFilePath) {
// Changing file path to full path
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return oAudioPlayer->preloadEffect(fullPath.c_str());
2012-08-02 13:02:59 +08:00
}
void SimpleAudioEngine::unloadEffect(const char* pszFilePath) {
// Changing file path to full path
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
return oAudioPlayer->unloadEffect(fullPath.c_str());
2012-08-02 13:02:59 +08:00
}
void SimpleAudioEngine::pauseEffect(unsigned int uSoundId) {
oAudioPlayer->pauseEffect(uSoundId);
}
void SimpleAudioEngine::pauseAllEffects() {
oAudioPlayer->pauseAllEffects();
}
void SimpleAudioEngine::resumeEffect(unsigned int uSoundId) {
oAudioPlayer->resumeEffect(uSoundId);
}
void SimpleAudioEngine::resumeAllEffects() {
oAudioPlayer->resumeAllEffects();
}
void SimpleAudioEngine::stopAllEffects() {
oAudioPlayer->stopAllEffects();
}
//////////////////////////////////////////////////////////////////////////
// volume interface
//////////////////////////////////////////////////////////////////////////
float SimpleAudioEngine::getBackgroundMusicVolume() {
return oAudioPlayer->getBackgroundMusicVolume();
}
void SimpleAudioEngine::setBackgroundMusicVolume(float volume) {
return oAudioPlayer->setBackgroundMusicVolume(volume);
}
float SimpleAudioEngine::getEffectsVolume() {
return oAudioPlayer->getEffectsVolume();
2012-08-02 13:02:59 +08:00
}
void SimpleAudioEngine::setEffectsVolume(float volume) {
return oAudioPlayer->setEffectsVolume(volume);
}
} // end of namespace CocosDenshion
2013-07-05 16:28:06 +08:00
#endif