"FSBank Error: The format of the source file is invalid."

Hi, I have been trying to automate a process for building FSBs using the FSBANK api but I am running into an error when trying to build some banks “The format of the source file is invalid.”:

std::vector<const char*> fileNames; // absolute paths to .wavs

FSBANK_SUBSOUND subSound = {};
subSound.fileNames = fileNames.data();
subSound.numFiles = static_cast<unsigned int>(fileNames.size());

const FSBANK_SUBSOUND* subSounds = &subSound;

fs::path fsbPath = dir / (stem + ".fsb");

std::cout << "Building FSB: " << fsbPath << "\n";
ERRCHECK(FSBank_Build(subSounds, 1, FSBANK_FORMAT_PCM, FSBANK_BUILD_DEFAULT, 0, nullptr, fsbPath.string().c_str()));

It’s only some of my banks that get this error too.

But what gets me is that using fsbank.exe seems to happily build the bank with the same .wavs!


.

I also get the error “An invalid parameter has been passed to this function.” on FSBank_Build for some other banks – while these .wav files also build successfully in fsbank.exe.

What am I missing?

Hi! If possible, could I get you to upload the problem wavs to your FMOD user profile for me to take a look at on my end?

Hi! Apologies for the late response - I don’t think I am able to provide these files publicly, but I can show details of the file.

This is one of the problem wav files:

This has actually been converted from a Playstation 2 .vag file using FFMPEG.
image

I don’t have a great deal of experience with audio, so I may have missed something fairly obvious here - I appreciate the help.

Something I’ve actually noticed is that multiple files that I am trying to build into the same .FSB do have different sample rates.
For example,
File 1 - 22042 Hz
File 2 - 11015 Hz
File 3 - 24000 Hz

I’ve identified the error here and have been able to fix it.

I misunderstood the documentation of FSBANK_SUBSOUND – Specifically, “fileNames - List of file names used to produce an interleaved sound.”.

I assumed this was where I was to provide the paths to all of my waves that I wanted to build into the .fsb, but the correct way to do it is to have an FSBANK_SUBSOUND for each sub sound (should be obvious, right? My mistake…)

My updated, correct code:

std::vector<FSBANK_SUBSOUND> subSounds;
std::vector<std::vector<const char *>>
    subSoundFileNames; // Need to keep strings in scope...
for (const auto &fileName : wavFileNames)
{
    subSoundFileNames.push_back({fileName.c_str()});

    FSBANK_SUBSOUND subSound = {0};
    subSound.fileNames = subSoundFileNames.back().data();
    subSound.numFiles = 1;

    subSounds.push_back(subSound);
}

ERRCHECK(FSBank_Build(subSounds.data(), static_cast<unsigned int>(subSounds.size()),
                      FSBANK_FORMAT_PCM, FSBANK_BUILD_DEFAULT, 0, nullptr, outputPath);

This actually builds a set of wavs into a single .fsb, which was my intention.