HTML5 API - "Random" multi instruments always play the same sub-instrument

HTML5 engine - 2.03.03

I have not tested this in any other engine, but can consistently reproduce it in the JS engine with any project.

Steps to reproduce:

  • Create event with multi instrument
  • Add a few unique sub-instruments
  • Set playlist mode to “Random”
  • Play event in HTML5 (and try playing the event multiple times in one session)

It seems like the internal RNG always outputs the same sequence of values or something like that. When I repeatedly play a multi instrument with 4 sub-instruments, it consistently chooses:

  • the second instrument
  • the second instrument
  • the second instrument
  • the fourth instrument
  • the first instrument
  • the third instrument
    …etc

and it’s the same for any multi instrument with 4 sub-instruments, and seemingly the same (just scaled) with any other number of instruments in a playlist.

I’ve noticed that the core system’s “advanced settings” has a randomSeed parameter, but changing it doesn’t seem to affect this RNG.

You are correct, the “random” playlist mode will always playback in the same order due to it using the same randomization seed, we have a section in the docs about this: events are too deterministic during runtime.

I was able to change the order that the randomized instrument played the assets by using this before the Studio System is initialized:

...
    //rand seed
    var advSettings = {};
    result = gSystemCore.getAdvancedSettings(advSettings);
    CHECK_RESULT(result);
    advSettings.randomSeed = 2;
    result = gSystemCore.setAdvancedSettings(advSettings);
    CHECK_RESULT(result);
...

Thanks. I wasn’t aware of the troubleshooting page and it makes sense now that the seed must be set before Studio System initialization.

getAdvancedSettings consistently throws ERR_INVALID_PARAM but fills in the object with the correct keys, with all zeroes as values.

However, setAdvancedSettings does work and I am able to pass in the default values listed in the documentation.

const advancedSettings = {
    maxMPEGCodecs: 32,
    maxADPCMCodecs: 32,
    maxXMACodecs: 32,
    maxVorbisCodecs: 32,
    maxAT9Codecs: 32,
    maxFADPCMCodecs: 32,
    maxOpusCodecs: 32,
    ASIONumChannels: 0,
    vol0virtualvol: 0,
    defaultDecodeBufferSize: 400,
    profilePort: 9264,
    geometryMaxFadeTime: 500,
    distanceFilterCenterFreq: 1500,
    reverb3Dinstance: 0,
    DSPBufferPoolSize: 8,
    resamplerMethod: 0,
    randomSeed: Math.floor(Math.random() * 4294967295), // max unsigned 32-bit integer
    maxConvolutionThreads: 3,
    maxSpatialObjects: 0,
};

this.assert(this.core.setAdvancedSettings(advancedSettings));
1 Like