FSBank generating sound with imbalanced volume

Hello,

As the title says, I’m encountering an issue where FSBank_Build is generating banks that have imbalanced volume levels.

The second sound that is passed into an FSBank_Subsound::fileData array consistently is very quiet on playback, even though channel volume is sure to be 1. Playback is in Chrome/Safari with HTML5 Wasm FMOD 2.02.18. I’ve also swapped the file build order, and the second sound is always the quiet one, so it seems like the files aren’t the issue (standard .wav exported from Logic Pro).

Since building the same files with the FSBank utility app works as expected, I probably have something wrong in my code.

FSBank_Init is called before building with:

const auto NumCores = std::thread::hardware_concurrency();
FSB_CHECK(
    FSBank_Init(
        FSBANK_FSBVERSION_FSB5,
        FSBANK_INIT_DONTLOADCACHEFILES,
        NumCores,
        CacheDirectory)
);

And here is my code for building - files is an std::vector<void *> holding the buffers, and fileSizes is an std::vector<unsigned> with the corresponding byte sizes of each.

  // Prepare subsound
  auto subsound = FSBANK_SUBSOUND();
  std::memset(&subsound, 0, sizeof(FSBANK_SUBSOUND));

  subsound.desiredSampleRate = samplerate;
  subsound.numFiles = files.size();
  subsound.fileData = files.data();
  subsound.fileDataLengths = fileSizes.data();

  // Build
  FSB_CHECK( FSBank_Build(&subsound, 1, BankFormat,
      FSBANK_BUILD_DEFAULT, 75, nullptr, nullptr) );

FMOD version is 2.02.18
System: M1 Mac OS Sonoma

(It appears that libfsbvorbis and libopus for this version are only available for the x86_64 platform so I am building to FADPCM format.)

Thanks in advance for any insight, I have no idea what might be causing this.

I just tried to create the bank with multiple FSBANK_SUBSOUND instead of multiple sounds arrayed into one as I did above, and now it’s working as expected.

// Collect subsounds
std::vector<FSBANK_SUBSOUND> subsounds;
for (int i = 0; i < files.size(); ++i)
{
    auto &subsound = subsounds.emplace_back();
    std::memset(&subsound, 0, sizeof(FSBANK_SUBSOUND));

    subsound.desiredSampleRate = samplerate;
    subsound.numFiles = 1;
    subsound.fileData = &files[i];
    subsound.fileDataLengths = &fileSizes[i];
}

// Run build
FSB_CHECK( FSBank_Build(subsounds.data(), subsounds.size(), BankFormat,
    FSBANK_BUILD_DEFAULT, 75, nullptr, nullptr) );

Hope this helps anyone else running into this issue.

Is this the intended behavior or could this possibly be a bug?

Hi,

Thank you for bringing this to our attention and sharing the solution. I am still investigating the issue and if I can confirm the bug I will update the thread.

1 Like