开发者

How to pass a sound name to Fmod on iPhone

Is there a way to get fmod to play a sound based on sound name? I can loop out the sound name by using this code:

    for (int subsoundindex = 0; subsoundindex < numsubsounds; subsoundindex++)
    {
            FMOD::Sound *subsound  = NULL;
          开发者_如何学运维  char         name[256] = {0};

            result = fsb->getSubSound(subsoundindex, &subsound);
            ERRCHECK(result);

            result = subsound->getName(name, 256);
            ERRCHECK(result);

        NSLog(@"SOUND NAME %s.", name);
    }

But to play it I want to know where to inject the sound name in a code like this:

    result = fsb->getSubSound(row, &subsound);

    ERRCHECK(result);        

    result = system->playSound(FMOD_CHANNEL_FREE, subsound, false, &channel);
    ERRCHECK(result);


It is not possible to get an FSB subsound by name, you must always use the index. There are a couple of options available to you however.

  1. You could create a list of names, then look up the name to get the index (this would probably be faster than scanning each subsound.

  2. You could use an include header, FSBankLib can produce a header file generated from the names that go into the FSB which you can use as macros to the index of a subsound.

  3. You could use FMOD Designer, and instead of Sounds, use Events, these can be looked up by name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜