Multi Sound Playlist Shuffle is Not Randomizing?

The playlist in a multi sound object appears to play in a shuffled order when shuffle is enabled but it seems to always play the SAME shuffled order every time I restart my application.

This is obviously not desired behaviour - why does the shuffle function not have a random seed set each time the bank is loaded?

Is there any way to actually randomize the play list of a multi sound object properly?

EDIT: Just want to note that this behaviour is not evident INSIDE Studio as it plays randomly all the time, it only happens when I’m using the events from within my app.

EDIT 2: Using the following code - still no change in behaviour. Tried setAdvancedSettings both before and after system->initialize, with no change. Not seeing any errors. cbSize is 108, and random seed (as expected) is always different and greater than 2. Any idea what I’m doing wrong?

    system = NULL;
	ERRCHECK(FMOD::Studio::System::create(&system));
	
	lowLevelSystem = NULL;
	ERRCHECK(system->getLowLevelSystem(&lowLevelSystem));
	ERRCHECK(lowLevelSystem->setSoftwareFormat(0, FMOD_SPEAKERMODE_STEREO, 0));

	FMOD_ADVANCEDSETTINGS settings;
	settings.randomSeed = util.randInt(2, 10000);
	settings.cbSize = sizeof(FMOD_ADVANCEDSETTINGS);
	std::cout << " settings.cbSize= " << settings.cbSize << "  settings.randomSeed =" << settings.randomSeed << "\n";
	ERRCHECK(lowLevelSystem->setAdvancedSettings(&settings));


	ERRCHECK(system->initialize(1024, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData));

Hi Nicholas,

Randomisation in Multi Sounds is based on the random seed provided by your FMOD initialization settings. By default, the random seed will default to 0, meaning that you will get the same shuffled order deterministically, each time you start up your game.

You can read more about Random Seeds here:

Our Unreal Engine 4 and Unity integrations both set the random seed to the system time, so you should get a quasi-random behaviour in game.

If you are using a custom integration, you can set the random seed on the advance settings struct by using the System::setAdvancedSettings function and setting FMOD_ADVANCEDSETTINGS.randomSeed. Please see our API documentation for more details:
http://www.fmod.org/documentation/#content/generated/FMOD_System_SetAdvancedSettings.html
http://www.fmod.org/documentation/#content/generated/FMOD_ADVANCEDSETTINGS.html

1 Like

Thanks for the info - having trouble implementing it. See edit above for code.

Hi Nicholas,

You need to make sure that you are setting these settings before FMOD Studio is initialised. Could you let me know how you are building your game (Unity, UE4, custom?)?

1 Like

Using Visual Studio Community 2015 with C++. Code above shows that I’m doing it before initialize - what else can I try?

Hi Nicholas,

Your code looks correct and should work, which leads me to believe there might be an issue elsewhere in your game code. Unfortunately without seeing the source code we can’t really offer further advice.

Are you able to reproduce this in a separate project (eg. press a button to play the multi sound)?

Hello, also having this issue. Multisound instruments are not randomized correctly.

Have you tried editing the random seed before initializing the FMOD system?

I realize this is a old question, but I also can’t get multi-instruments to be seeded at launch.

I am using C and not using Unity, etc.

	result = FMOD_Studio_System_Create(&_fmod_studio_system, FMOD_VERSION);
	FMOD_Studio_System_GetCoreSystem(_fmod_studio_system, &_fmod_system);
    ...
    FMOD_ADVANCEDSETTINGS settings2;
	settings2.cbSize = sizeof(settings2);
	FMOD_System_GetAdvancedSettings(_fmod_system, &settings2);
	settings2.randomSeed = 500; //(unsigned int)time(NULL);
	FMOD_System_SetAdvancedSettings(_fmod_system, &settings2);
    ...
	result = FMOD_Studio_System_Initialize(_fmod_studio_system, fmod_max_channels, fmod_studio_init_flags, fmod_init_flags, 0);

It doesn’t seem to matter what I set randomSeedto. I am using FMOD 2.03.08

Hi, sorry for the delayed response!

FMOD_ADVANCEDSETTINGS needs to have all of its values zeroed out before being passed to FMOD_System_SetAdvancedSettings in order to ensure they’re all at their default values. You can do this like so:

    FMOD_ADVANCEDSETTINGS settings2;
    memset(&settings2, 0, sizeof(FMOD_ADVANCEDSETTINGS)); //<--
    settings2.cbSize = sizeof(FMOD_ADVANCEDSETTINGS);
    settings2.randomSeed = 500;

This should ensure that the system accepts your provided advanced settings struct. You should be able to verify whether the values are set as expected by using the logging versions of the libs (L suffix) and setting your logging level to FMOD_DEBUG_LEVEL_LOG before system creation, like so:

FMOD_Debug_Initialize(FMOD_DEBUG_LEVEL_LOG, FMOD_DEBUG_MODE_TTY, 0, nullptr);

I do a GetSettings right before I change the one value, I would assume thay are set correct from the get?

If you check the return value of the FMOD_System_GetAdvancedSettings call, I expect you’ll find it’s returning an invalid parameter error (value 31). This is because even when retrieving the existing value, the system expects the struct to be zeroed out so that rogue/uninitialized values or pointers aren’t passed out of the FMOD system.

This isn’t explicitly noted in our documentation, so I’ve flagged the relevant API pages for improvements.