当前位置: 首页>>代码示例>>C++>>正文


C++ System::createSoundGroup方法代码示例

本文整理汇总了C++中fmod::System::createSoundGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ System::createSoundGroup方法的具体用法?C++ System::createSoundGroup怎么用?C++ System::createSoundGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fmod::System的用法示例。


在下文中一共展示了System::createSoundGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char * argv[])
{
    FMOD::System        *system;
    FMOD::Sound         *sound1, *sound2, *sound3;
    FMOD::SoundGroup    *soundgroup;
    FMOD::Channel       *channel[3];
    FMOD_RESULT          result;
    int                  key=0;
    int                  mode=1;
    unsigned int         version;

    printf("======================================================================\n");
    printf("soundgroups Example.  Copyright (c) Firelight Technologies 2004-2014.\n");
    printf("======================================================================\n");
    printf("This example plays 3 sounds in a sound group, demonstrating the effect\n");
    printf("of the three different sound group behavior modes\n");
    printf("======================================================================\n\n");

    /*
        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(100, FMOD_INIT_NORMAL, 0);
    ERRCHECK(result);
    	
	/*
	    Load some sound files from the hard disk.
	*/
	result = system->createSound("../media/drumloop.wav", FMOD_HARDWARE |  FMOD_LOOP_NORMAL, 0, &sound1);
	ERRCHECK(result);

	result = system->createSound("../media/jaguar.wav", FMOD_HARDWARE | FMOD_LOOP_NORMAL, 0, &sound2);
	ERRCHECK(result);

	result = system->createSound("../media/swish.wav", FMOD_HARDWARE | FMOD_LOOP_NORMAL, 0, &sound3);
	ERRCHECK(result);
    
    /* 
        Create the sound group with the following attributes:
          Name       = MyGroup
          MaxAudible = 1
          Behavior   = Mute 
    */
	result = system->createSoundGroup("MyGroup",&soundgroup);
	ERRCHECK(result);

    result = soundgroup->setMaxAudible(1);
    ERRCHECK(result);

    result = soundgroup->setMaxAudibleBehavior(FMOD_SOUNDGROUP_BEHAVIOR_MUTE);
    ERRCHECK(result);

    result = soundgroup->setMuteFadeSpeed(2);
    ERRCHECK(result);

    /*
        Put the sounds in the sound group
    */
	result = sound1->setSoundGroup(soundgroup);
	ERRCHECK(result);

	result = sound2->setSoundGroup(soundgroup);
	ERRCHECK(result);

	result = sound3->setSoundGroup(soundgroup);
	ERRCHECK(result);
	
    
	/*
        Play the sounds (two will be muted because of the behavior mode)
    */
	result = system->playSound(FMOD_CHANNEL_FREE, sound1,false,&channel[0]);
	ERRCHECK(result);	

	result = system->playSound(FMOD_CHANNEL_FREE, sound2,false,&channel[1]);
	ERRCHECK(result);

	result = system->playSound(FMOD_CHANNEL_FREE, sound3,false,&channel[2]);
	ERRCHECK(result);
    
    /*
        Display help
    */
    printf("=========================================================================\n");
    printf("Press 1        BEAVIOR_FAIL \n");
    printf("      2        BEAVIOR_MUTE \n");
    printf("      3        BEAVIOR_STEALLOWEST\n");
    printf("      Q        Play/stop drumloop sound\n");
    printf("      W        Play/stop Jaguar sound\n");
//.........这里部分代码省略.........
开发者ID:Guitaroz,项目名称:Arcade-Space-Shooter,代码行数:101,代码来源:main.cpp


注:本文中的fmod::System::createSoundGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。