Sound.lock() returning ERR_INVALID_PARAM


I am trying to lock a sound to use the data in some other code (JavaScript/WASM, HTML5 build of FMOD), but the Sound.lock() function always returns 31 (ERR_INVALID_PARAM). How do I use this function properly? The documentation does not provide any sort of example or special conditions, so I’m just integrating it as I would any other FMOD function. I have confirmed that using system.playSound() works fine, however. This is my code:

// ...
let ptr1 = {};
let ptr2 = {};
let len1 = {};
let len2 = {};
if ((res = sound.lock(0, 128, ptr1, ptr2, len1, len2)) !== 0) {  // lock to read 128 bytes (0-128)
  console.error('Could not lock sound for reading', res);
// ...


Thanks for bringing this to our attention. I’ve been able to reproduce the issue on my end, and it appears that Sound::lock on HTML5 is improperly implemented. I’ve passed this along to the development team for further investigation.There may be a few ways to work around this issue, depending on your exact use-case - can I get you to expand on what you’re trying to accomplish in more detail?