本文整理汇总了C++中fmod::Sound::setMode方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::setMode方法的具体用法?C++ Sound::setMode怎么用?C++ Sound::setMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::Sound
的用法示例。
在下文中一共展示了Sound::setMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlayMusic
DWORD FmodSoundEngine::PlayMusic(string filename, CHANNEL Ichannel, bool loop, float volume)
{
if(Ichannel<0||Ichannel>=maxChannel)
{
Ichannel = GetNewChannel();
if(Ichannel<0)
{
PlaySound(filename,volume);
return NULL;
}
}
nowChannel = max(nowChannel,Ichannel+1);
FMOD::Sound *sound = (FMOD::Sound*)ReadMusic(Ansi2UTF8(filename).data());
FMOD::Channel **channel = (FMOD::Channel**)this->channel;
if(loop)
{
result = sound->setMode(FMOD_LOOP_NORMAL);
//ERRCHECK(result);
}
result = system->playSound(sound, NULL, true, &channel[Ichannel]);
//ERRCHECK(result);
volumeDes[Ichannel] = volume*defaultVolume;
result = channel[Ichannel]->setVolume(volumeDes[Ichannel]);
//ERRCHECK(result);
result = channel[Ichannel]->setPaused(false);
//ERRCHECK(result);
return (DWORD)sound;
}
示例2:
SkySound SoundManager::play3DSound(std::string name, float volume, float x, float y, float z, bool echo, bool loop, float fallOffStart)
{
if(mSilent) return NULL;
if ("" == name)
return false;
if(mInitFailed) return NULL;
FMOD::Sound* sound = 0;
FMOD::Channel* soundChannel;
result = mSystem->createSound(name.c_str(), FMOD_SOFTWARE | FMOD_3D, 0, &sound);
if (!sound)
{
printf("FMOD Error loading %s!\n", name.c_str());
checkErrors();
return NULL;
}
sound->set3DMinMaxDistance(fallOffStart, 2000);
sound->setMode(loop ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
mSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &soundChannel);
// if(echo)
// soundChannel->addDSP(mReverb);
FMOD_VECTOR pos = {x, y, z};
FMOD_VECTOR vel = {0, 0, 0};
soundChannel->setVolume(volume);
soundChannel->set3DAttributes(&pos, &vel);
mSystem->update();
// printf("finished play3dsound\n");
return soundChannel;
}
示例3: ERRCHECK
FMOD::Sound* AudioManager::PlaySound2D(FMOD::Channel** pChannel, const char* filename, bool looping, bool stream)
{
if (m_audioEnabled)
{
FMOD::Sound* sound;
*pChannel = NULL;
FMOD::ChannelGroup *channelGroup = NULL;
if (stream)
{
m_FMODResult = m_FMODSystem->createStream(filename, FMOD_DEFAULT | FMOD_2D, 0, &sound);
}
else
{
m_FMODResult = m_FMODSystem->createSound(filename, FMOD_DEFAULT | FMOD_2D, 0, &sound);
}
ERRCHECK(m_FMODResult);
m_FMODResult = sound->setMode(looping == true ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
ERRCHECK(m_FMODResult);
m_FMODResult = m_FMODSystem->playSound(sound, channelGroup, false, pChannel);
ERRCHECK(m_FMODResult);
return sound;
}
return NULL;
}
示例4: setup
void _TBOX_PREFIX_App::setup()
{
FMOD::System_Create( &mSystem );
mSystem->init( 32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, NULL );
mSystem->createSound( getAssetPath( "Blank__Kytt_-_08_-_RSPN.mp3" ).string().c_str(), FMOD_SOFTWARE, NULL, &mSound );
mSound->setMode( FMOD_LOOP_NORMAL );
mSystem->playSound( FMOD_CHANNEL_FREE, mSound, false, &mChannel );
}
示例5: InitializeResource
void AudioClass::InitializeResource()
{
FMOD_RESULT result;
FMOD::Sound* snd;
result = m_system->createSound("Resource\\explode.wav", FMOD_HARDWARE, 0, &snd);
ERRCHECK(result);
snd->setMode(FMOD_LOOP_OFF);
SoundClass* sc = new SoundClass();
sc->Initialize(snd, "explode");
m_soundList.push_back(sc);
}
示例6: playSound
SkySound* KSoundManager::playSound(std::string name, float volume, float stereo, bool loop)
{
if(mSilent) return NULL;
if ("" == name) return NULL;
FMOD::Sound* sound;
result = mSystem->createSound(name.c_str(), FMOD_SOFTWARE | FMOD_2D, 0, &sound);
checkErrors();
if(!sound) printf("Error playing %s\n", name.c_str());
if (!sound) return NULL;
FMOD::Channel* soundChannel;
sound->setMode(loop ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
mSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &soundChannel);
soundChannel->setPan(stereo);
soundChannel->setVolume(volume);
mSystem->update();
return soundChannel;
}
示例7: loopMusic
//A method to play background music. The music will loop continually, and only one song can be played
//at a time
void SoundManager::loopMusic(const char* filePath)
{
if(!initialized)
{
FMOD::System_Create(&system);
system->init(100, FMOD_INIT_NORMAL, 0);
initialized = true;
}
if(backgroundPlaying)
{
//Stop the background before starting the new song
stopMusic();
}
FMOD::Sound *sound;
FMOD_RESULT result = system->createStream(filePath, FMOD_DEFAULT, 0, &sound);
sound->setMode(FMOD_LOOP_NORMAL);
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &bgMusic);
backgroundPlaying = true;
}
示例8: createStreamingSound
FMOD::Sound* FMODAudioClip::createStreamingSound() const
{
if(getReadMode() != AudioReadMode::Stream || mStreamData == nullptr)
{
LOGERR("Invalid audio stream data.");
return nullptr;
}
FMOD_MODE flags = FMOD_CREATESTREAM;
FMOD_CREATESOUNDEXINFO exInfo;
memset(&exInfo, 0, sizeof(exInfo));
exInfo.cbsize = sizeof(exInfo);
// Streaming from memory not supported.
assert(mStreamData->isFile());
exInfo.length = mStreamSize;
exInfo.fileoffset = mStreamOffset;
SPtr<FileDataStream> fileStream = std::static_pointer_cast<FileDataStream>(mStreamData);
String pathStr = fileStream->getPath().toString();
if (is3D())
flags |= FMOD_3D;
else
flags |= FMOD_2D;
FMOD::Sound* sound = nullptr;
FMOD::System* fmod = gFMODAudio()._getFMOD();
if (fmod->createSound(pathStr.c_str(), flags, &exInfo, &sound) != FMOD_OK)
{
LOGERR("Failed creating a streaming sound.");
return nullptr;
}
sound->setMode(FMOD_LOOP_OFF);
return sound;
}
示例9:
SkySound* KSoundManager::play3DSound(std::string name, float volume, float x, float y, float z, bool loop, float fallOffStart, float delay)
{
if(mSilent) return NULL;
if ("" == name) return NULL;
if(mInitFailed) return NULL;
FMOD::Sound* sound = 0;
FMOD::Channel* soundChannel;
result = mSystem->createSound(name.c_str(), FMOD_SOFTWARE | FMOD_3D, 0, &sound);
if (!sound)
{
printf("FMOD Error loading %s!\n", name.c_str());
checkErrors();
return NULL;
}
sound->set3DMinMaxDistance(fallOffStart, 2000);
sound->setMode(loop ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
bool delayed = (delay > 0);
mSystem->playSound(FMOD_CHANNEL_FREE, sound, delayed, &soundChannel);
FMOD_VECTOR pos = {x, y, z};
FMOD_VECTOR vel = {0, 0, 0};
soundChannel->setVolume(volume);
soundChannel->set3DAttributes(&pos, &vel);
mSystem->update();
//if this sound is delayed, queue it up
if(delayed)
{
DelayedSound s;
s.delay = delay;
s.sound = soundChannel;
mDelayedSounds.push_back(s);
}
return soundChannel;
}
示例10: addToPlayList
bool Music::addToPlayList(TCHAR* fileName)
{
if(_ifExist(fileName,_soundList))
{
return false;
}
else
{
//´´½¨ÒôÀÖÁ÷
FMOD::Sound* soundTemp;
try{
_system->createStream(fileName, FMOD_HARDWARE, 0, &soundTemp);} //´´½¨ÉùÒô
catch(...)
{
}
soundTemp->setMode(FMOD_LOOP_OFF); //¹Ø±ÕÑ»·
SoundStruct* temp = new SoundStruct;
temp->soundName = new TCHAR[MAX_PATH];
strcpy(temp->soundName,fileName);
//temp->channel = soundTemp;
_soundList.insert(std::make_pair(temp,soundTemp));
_soundListSize = _soundList.size();
return true;
}
}
示例11: playSound
bool SoundManager::playSound(std::string name, float volume, float stereo, bool echo, bool loop)
{if(mSilent) return true;
if ("" == name)
return false;
//fading = false;
FMOD::Sound* sound;
result = mSystem->createSound(name.c_str(), FMOD_SOFTWARE | FMOD_2D, 0, &sound);
checkErrors();
if (!sound) return false;
FMOD::Channel* soundChannel;
sound->setMode(loop ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
mSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &soundChannel);
// if(echo)
// soundChannel->addDSP(mEcho);
soundChannel->setPan(stereo);
soundChannel->setVolume(volume);
// printf("finished play sound\n");
mSystem->update();
return true;
}
示例12: setup
void StepTwoApp::setup()
{
FMODListDevices();
FMODErrorCheck(FMOD::System_Create( &mSystem ));
FMODErrorCheck(mSystem->setDriver(0));
FMOD_INITFLAGS flags = FMOD_INIT_NORMAL; // right-click, Go To Definition
FMODErrorCheck(mSystem->init( 32, flags, NULL ));
vector<fs::path> paths;
paths.push_back( getAssetPath("gong-loud-hit.mp3") );
paths.push_back( getAssetPath("orch-hit.wav") );
paths.push_back( getAssetPath("trumpethit07.wav") );
for(auto& path: paths) {
FMOD::Sound* sound;
mSystem->createSound( path.string().c_str(), FMOD_SOFTWARE, NULL, &sound );
// You can change the mode of sounds at any time.
FMOD_MODE mode = FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_OFF;
FMODErrorCheck( sound->setMode( mode ) );
mSounds.push_back(sound);
}
}
示例13: main
//.........这里部分代码省略.........
printf("\n");
/*
Main loop.
*/
do
{
static FMOD::Channel *channel = 0;
static bool looping = false;
bool recording = false;
bool playing = false;
unsigned int recordpos = 0;
unsigned int playpos = 0;
unsigned int length;
if (kbhit())
{
key = getch();
switch (key)
{
case 'r' :
case 'R' :
{
result = system->recordStart(recorddriver, sound, looping);
ERRCHECK(result);
break;
}
case 'p' :
case 'P' :
{
if (looping)
{
sound->setMode(FMOD_LOOP_NORMAL);
}
else
{
sound->setMode(FMOD_LOOP_OFF);
}
ERRCHECK(result);
result = system->playSound(FMOD_CHANNEL_REUSE, sound, false, &channel);
ERRCHECK(result);
break;
}
case 'l' :
case 'L' :
{
looping = !looping;
break;
}
case 's' :
case 'S' :
{
result = system->recordStop(recorddriver);
if (channel)
{
channel->stop();
channel = 0;
}
break;
}
case 'w' :
case 'W' :
{
printf("Writing to record.wav ... \r");
示例14: playMusic
bool Music::playMusic(TCHAR* fileName,bool loop,bool single,float volume)
{
try{
FMOD::Sound* soundTemp = NULL;
std::map<SoundStruct*,FMOD::Sound*>::iterator ite;
for(ite=_recycle.begin();ite!=_recycle.end();ite++)
{
if((strcmp(((*ite).first)->soundName,fileName))==0)
{
soundTemp = (*ite).second;
if(single==true)
{
unsigned int curTime = static_cast<unsigned int>(timeGetTime());
if(curTime-((*ite).first)->_lastTime<((*ite).first)->_len+200)
return true;
else
{
((*ite).first)->_lastTime = curTime;
}
}
//soundTemp->
}
}
if(soundTemp==NULL)
{
if( FMOD_OK!=_system->createStream(fileName, FMOD_HARDWARE, 0, &soundTemp)) //´´½¨ÉùÒô
{
return false;
}
soundTemp->setMode(FMOD_LOOP_OFF); //¹Ø±ÕÑ»·
if(loop)
soundTemp->setMode(FMOD_LOOP_NORMAL);
else
soundTemp->setMode(FMOD_LOOP_OFF);
_system->playSound(FMOD_CHANNEL_FREE, soundTemp, false, &_channel);
_channel->setVolume(volume); //²¥·ÅÉùÒô
SoundStruct* temp = new SoundStruct;
temp->_lastTime = static_cast<unsigned int>(timeGetTime());
temp->soundName = new TCHAR[MAX_PATH];
strcpy(temp->soundName,fileName);
temp->channel = _channel;
unsigned int llen=0;
soundTemp->getLength(&llen,FMOD_TIMEUNIT_MS);
temp->_len = llen;
_recycle.insert(std::make_pair(temp,soundTemp));
return true;
}
if(loop)
soundTemp->setMode(FMOD_LOOP_NORMAL);
else
soundTemp->setMode(FMOD_LOOP_OFF);
_system->playSound(FMOD_CHANNEL_FREE, soundTemp, false, &_channel);
_channel->setVolume(volume); //²¥·ÅÉùÒô
}
catch(...)
{
}
return true;
}
示例15: Init
bool DuckHuntMain::Init()
{
if (!D3DApp::Init())
return false;
// Must init Effects first since InputLayouts depend on shader signatures.
Effects::InitAll(md3dDevice);
InputLayouts::InitAll(md3dDevice);
RenderStates::InitAll(md3dDevice);
mCrosshair = new Crosshair(md3dDevice);
mTexMgr.Init(md3dDevice);
DuckHuntMain::ShowCursors(false);
mSky = new Sky(md3dDevice, L"Textures/desertcube1024.dds", 5000.0f);
mSmap = new ShadowMap(md3dDevice, SMapSize, SMapSize);
Terrain::InitInfo tii;
tii.HeightMapFilename = L"Textures/myT5.raw";
tii.LayerMapFilename0 = L"Textures/grass.dds";
tii.LayerMapFilename1 = L"Textures/darkdirt.dds";
tii.LayerMapFilename2 = L"Textures/stone.dds";
tii.LayerMapFilename3 = L"Textures/lightdirt.dds";
tii.LayerMapFilename4 = L"Textures/snow.dds";
tii.BlendMapFilename = L"Textures/blend.dds";
tii.HeightScale = 50.0f;
tii.HeightmapWidth = 2049;
tii.HeightmapHeight = 2049;
tii.CellSpacing = 0.5f;
mTerrain.Init(md3dDevice, md3dImmediateContext, tii);
//Sound
result = FMOD::System_Create(&mSystem);
result = mSystem->init(32, FMOD_INIT_NORMAL, 0);
result = mSystem->createSound("Sounds/GunFire.wav", FMOD_DEFAULT, 0, &mGunFire);
result = mGunFire->setMode(FMOD_LOOP_OFF);
mCam.SetLens(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f);
mSsao = new Ssao(md3dDevice, md3dImmediateContext, mClientWidth, mClientHeight, mCam.GetFovY(), mCam.GetFarZ());
BuildScreenQuadGeometryBuffers();
testModelDuck = new BasicModel(md3dDevice, mTexMgr, "Models\\duck.obj", L"Textures\\DUCK.jpg");
BasicModelInstance testInstanceDuck;
BasicModelInstance testInstanceDuck2;
BasicModelInstance testInstanceDuck3;
BasicModelInstance testInstanceDuck4;
testInstanceDuck.Model = testModelDuck;
testInstanceDuck2.Model = testModelDuck;
testInstanceDuck3.Model = testModelDuck;
testInstanceDuck4.Model = testModelDuck;
//Duck 1
XMMATRIX modelScale = XMMatrixScaling(1.0f, 1.0f, -1.0f);
XMMATRIX modelRot = XMMatrixRotationY(0.0f);
XMMATRIX modelOffset = XMMatrixTranslation(0.0f, 0.0f, 0.0f);
//Duck 2
XMMATRIX modelScale2 = XMMatrixScaling(2.0f, 2.0f, -1.0f);
XMMATRIX modelRot2 = XMMatrixRotationY(-1.0f);
XMMATRIX modelOffset2 = XMMatrixTranslation(1.0f, 1.0f, -1.0f);
//Duck3
XMMATRIX modelScale3 = XMMatrixScaling(1.5f, 1.5f, 1.5f);
XMMATRIX modelRot3 = XMMatrixRotationY(0.5f);
XMMATRIX modelOffset3 = XMMatrixTranslation(2.0f, 1.0f, -1.0f);
//Duck4
XMMATRIX modelScale4 = XMMatrixScaling(0.5f, 0.5f, -1.0f);
XMMATRIX modelRot4 = XMMatrixRotationY(1.0f);
XMMATRIX modelOffset4 = XMMatrixTranslation(0.5f, 1.0f, -1.0f);
//Duck 1
XMStoreFloat4x4(&testInstanceDuck.World, modelScale*modelRot*modelOffset);
mModelInstances.push_back(testInstanceDuck);
//Duck 2
XMStoreFloat4x4(&testInstanceDuck2.World, modelScale2*modelRot2*modelOffset2);
mModelInstances.push_back(testInstanceDuck2);
//Duck 3
XMStoreFloat4x4(&testInstanceDuck3.World, modelScale3*modelRot3*modelOffset3);
mModelInstances.push_back(testInstanceDuck3);
//Duck 4
XMStoreFloat4x4(&testInstanceDuck4.World, modelScale4*modelRot4*modelOffset4);
mModelInstances.push_back(testInstanceDuck4);
//create collision box
for (unsigned i = 0; i < mModelInstances.size(); i++)
{
mModelInstances[i].Model->CreateCollisionBox(mModelInstances[i].Model->BasicVertices);
}
//.........这里部分代码省略.........