本文整理汇总了C++中fmod::Sound::setSubSound方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::setSubSound方法的具体用法?C++ Sound::setSubSound怎么用?C++ Sound::setSubSound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::Sound
的用法示例。
在下文中一共展示了Sound::setSubSound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* @author JoSch
* @date 08-03-2008
* @version 1.0
*/
void Fmod4SoundStitching::putSoundIntoSlot(unsigned int slot, CeGuiString label)
{
if (isValid())
{
FMOD_MODE mode = FMOD_DEFAULT;
if (is3d())
{
mode |= FMOD_3D;
}
else
{
mode |= FMOD_2D;
}
if (isLooping())
{
mode |= FMOD_LOOP_NORMAL;
}
else
{
mode |= FMOD_LOOP_OFF;
}
FMOD::Sound *sound;
FMOD_RESULT result = mDriver->_getFmodSystem()->createStream(
mSoundCache[label]->getName().c_str(),
mode,
NULL,
&sound);
CHECK_FMOD4_ERRORS(result);
if (mSoundSlots[slot] != NULL)
{
mSoundSlots[slot]->release();
}
mSoundSlots[slot] = sound;
result = sound->setSubSound(slot, sound);
CHECK_FMOD4_ERRORS(result);
}
}
示例2: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Sound *subsound[2];
FMOD_CREATESOUNDEXINFO exinfo;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key;
unsigned int subsoundid, sentenceid;
unsigned int version;
const char *soundname[NUMSOUNDS] =
{
"../media/e.ogg", /* Ma- */
"../media/d.ogg", /* ry */
"../media/c.ogg", /* had */
"../media/d.ogg", /* a */
"../media/e.ogg", /* lit- */
"../media/e.ogg", /* tle */
"../media/e.ogg", /* lamb, */
"../media/e.ogg", /* ..... */
"../media/d.ogg", /* lit- */
"../media/d.ogg", /* tle */
"../media/d.ogg", /* lamb, */
"../media/d.ogg", /* ..... */
"../media/e.ogg", /* lit- */
"../media/e.ogg", /* tle */
"../media/e.ogg", /* lamb, */
"../media/e.ogg", /* ..... */
"../media/e.ogg", /* Ma- */
"../media/d.ogg", /* ry */
"../media/c.ogg", /* had */
"../media/d.ogg", /* a */
"../media/e.ogg", /* lit- */
"../media/e.ogg", /* tle */
"../media/e.ogg", /* lamb, */
"../media/e.ogg", /* its */
"../media/d.ogg", /* fleece */
"../media/d.ogg", /* was */
"../media/e.ogg", /* white */
"../media/d.ogg", /* as */
"../media/c.ogg", /* snow. */
"../media/c.ogg", /* ..... */
"../media/c.ogg", /* ..... */
"../media/c.ogg", /* ..... */
};
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
return 0;
}
result = system->init(1, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
/*
Set up the FMOD_CREATESOUNDEXINFO structure for the user stream with room for 2 subsounds. (our subsound double buffer)
*/
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.defaultfrequency = 44100;
exinfo.numsubsounds = 2;
exinfo.numchannels = 1;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
/*
Create the 'parent' stream that contains the substreams. Set it to loop so that it loops between subsound 0 and 1.
*/
result = system->createStream(0, FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
/*
Add 2 of our streams as children of the parent. They should be the same format (ie mono/stereo and bitdepth) as the parent sound.
When subsound 0 has finished and it is playing subsound 1, we will swap subsound 0 with a new sound, and the same for when subsound 1 has finished,
causing a continual double buffered flip, which means continuous sound.
*/
result = system->createStream(soundname[0], FMOD_DEFAULT, 0, &subsound[0]);
ERRCHECK(result);
result = system->createStream(soundname[1], FMOD_DEFAULT, 0, &subsound[1]);
ERRCHECK(result);
result = sound->setSubSound(0, subsound[0]);
ERRCHECK(result);
result = sound->setSubSound(1, subsound[1]);
ERRCHECK(result);
//.........这里部分代码省略.........