0
0

I have an FSB with various voice comments of different lengths. Some comments are one subsound and some require a few subsounds stitched together. So I open the bank as a stream and use setSubSoundSentence to tell it which ones to play. I am also setting the initial subsound when the stream is created.

When I use any compressed format (adpcm, mp2, mp3) I get either static at the end of certain subsounds, or parts of the beginning/end ar cut off, or part of another subsound is also played.

I modified the fsb example to reproduce the problem, the code is below. I also have an fsb I can send if necessary.

Thanks

[code:3nw22z7m]
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *fsb;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key, count, numsubsounds;
unsigned int version;

//--- Start my change
FMOD::Sound      *sentence = NULL;
const char*      pFilename = "../media/voicetest_adpcm.fsb";
//--- End my change

/*
    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(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);

//--- Start my change
result = system->createSound(pFilename, FMOD_DEFAULT, 0, &fsb);
//--- End my change
ERRCHECK(result);

printf("===================================================================\n");
printf("FSB Example.  Copyright (c) Firelight Technologies 2004-2005.\n");
printf("===================================================================\n");
printf("\n");

result = fsb->getNumSubSounds(&numsubsounds);
ERRCHECK(result);

//--- Start my change
//limit the list to 10 subsounds
if (numsubsounds > 10)
{
    numsubsounds = 10;
}
//--- End my change

for (count = 0; count < numsubsounds; count++)
{
    FMOD::Sound *subsound;
    char name[256];

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

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

    printf("Press '%c' to play \"%s\"\n", '1' + count, name);
}
printf("Press 'Esc' to quit\n");
printf("\n");

/*
    Main loop.
*/
do
{
    if (kbhit())
    {
        key = getch();

        if (key >= '1' && key < '1' + numsubsounds)
        {
            FMOD::Sound *subsound;
            int index = key - '1';

            //--- Start my change
            if (sentence == NULL)
            {
                FMOD_CREATESOUNDEXINFO soundInfo;
                memset(&soundInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
                soundInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
                soundInfo.initialsubsound = index;

                result = system->createSound(pFilename, FMOD_DEFAULT | FMOD_CREATESTREAM, &soundInfo, &sentence);
                ERRCHECK(result);

                //int sentenceList [3] = { 0, 4, 6 };
                int sentenceList [1] = { 0 };
                sentenceList[0] = index;

                result = sentence->setSubSoundSentence(sentenceList, 1);
                ERRCHECK(result);

                result = system->playSound(FMOD_CHANNEL_FREE, sentence, false, &channel);
                ERRCHECK(result);
            }
            //--- End my change
        }
    }

    system->update();

    {
        unsigned int ms = 0;
        unsigned int lenms = 0;
        bool         playing = 0;
        bool         paused = 0;
        int          channelsplaying = 0;

        if (channel)
        {
            FMOD::Sound *currentsound = 0;

            result = channel->isPlaying(&playing);
            if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
            {
                ERRCHECK(result);
            }

            //--- Start my change
            //clean up the sentence when it's done
            if ( !playing && (sentence != NULL) )
            {
                sentence->release();
                sentence = NULL;
            }
            //--- End my change

            result = channel->getPaused(&paused);
            if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
            {
                ERRCHECK(result);
            }

            result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
            if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
            {
                ERRCHECK(result);
            }

            channel->getCurrentSound(&currentsound);
            if (currentsound)
            {
                result = currentsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
                if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
                {
                    ERRCHECK(result);
                }
            }
        }

        system->getChannelsPlaying(&channelsplaying);

        printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying);
    }

    Sleep(10);

} while (key != 27);

printf("\n");

/*
    Shut down
*/
result = fsb->release();
ERRCHECK(result);
result = system->close();
ERRCHECK(result);
result = system->release();
ERRCHECK(result);

return 0;

}
[/code:3nw22z7m]

  • You must to post comments
0
0

Any ideas on this? It seems like it is only an issue on Win32.

  • You must to post comments
0
0

I have just done a quick run through test of your code and it seems to work as intended, can you send your FSB to support@fmod.org if it’s small, otherwise could you upload it to:

http://ftp.fmod.org
u: upload
p: upload

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.