I am getting some mysterious error when use FSBANK_BUILD()
the FSBANK_RESULT returns an error FSBANK_ERR_MEMORY
I dont know why I am getting it
if someone knows where I am wrong then please guide
Here is the C++ code
FSBANK_INITFLAGS InitFLAGS;
FSBANK_RESULT result;
string cachePath;
FSBANK_SUBSOUND subsound;
FSBANK_FORMAT format;
FSBank void SET_FSBANK_INIT_FLAG(int flag)
{
InitFLAGS = flag;
}
FSBank void SET_FSBANK_CACHE_PATH(const char* path)
{
cachePath = path;
}
FSBank int INIT_FSBANK(int quality)
{
result = FSBank_Init(FSBANK_FSBVERSION_FSB5, InitFLAGS, quality, cachePath.c_str());
return result;
}
FSBank void SetSubsoundNULL()
{
subsound = { NULL };
}
FSBank void SUB_SOUND_FILE_PATHS(const char* Path)
{
string sec = Path;
const char* const s = sec.c_str();
subsound.fileNames = &s;
}
FSBank void SUB_SOUND_OVER_RIDE_FLAG(int flag)
{
subsound.overrideFlags = flag;
}
FSBank void SUB_SOUND_OVER_RIDE_QUALITY(int quality)
{
subsound.overrideQuality = quality;
}
FSBank void SUB_SOUND_DESIRED_SAMPLE_RATE(int rate)
{
subsound.desiredSampleRate = rate;
}
FSBank void SUB_SOUND_SAMPLE_NUMBER(int num)
{
subsound.numFiles = num;
}
FSBank void FSB5_FSBANK_FORMAT(int formatENum)
{
format = (FSBANK_FORMAT)formatENum;
}
FSBank int FSBANK_BUILD(int numberOfSubSounds, int quality, const char* SavePath)
{
string saved = SavePath;
const FSBANK_SUBSOUND* newSubsound = &subsound;
FSBANK_RESULT result = FSBank_Build(newSubsound, (unsigned int)numberOfSubSounds, format, FSBANK_BUILD_DEFAULT | FSBANK_BUILD_DONTLOOP, (unsigned int)quality, NULL, saved.c_str());
return result;
}
Here are the C# bindings
const string dllName = "FSBankNative.dll";
[DllImport(dllName)]
public static extern void SET_FSBANK_INIT_FLAG(int flag);
[DllImport(dllName)]
public static extern void SET_FSBANK_CACHE_PATH(string path);
[DllImport(dllName)]
public static extern int INIT_FSBANK(int quality);
[DllImport(dllName)]
public static extern void SetSubsoundNULL();
[DllImport(dllName)]
public static extern void SUB_SOUND_FILE_PATHS(string Path);
[DllImport(dllName)]
public static extern void SUB_SOUND_OVER_RIDE_FLAG(int flag);
[DllImport(dllName)]
public static extern void SUB_SOUND_OVER_RIDE_QUALITY(int quality);
[DllImport(dllName)]
public static extern void SUB_SOUND_DESIRED_SAMPLE_RATE(int rate);
[DllImport(dllName)]
public static extern void SUB_SOUND_SAMPLE_NUMBER(int num);
[DllImport(dllName)]
public static extern void FSB5_FSBANK_FORMAT(int formatENum);
[DllImport(dllName)]
public static extern int FSBANK_BUILD(int numberOfSubSounds, int quality, string SavePath);
here is the C# code
FSBankLib.SET_FSBANK_INIT_FLAG((int)FSBankLib.FSBANK_INITFLAGS.FSBANK_INIT_NORMAL);
FSBankLib.SET_FSBANK_CACHE_PATH("G:/cache");
FSBankLib.FSBANK_RESULT result = (FSBankLib.FSBANK_RESULT)FSBankLib.INIT_FSBANK(2);
Console.WriteLine(result);
FSBankLib.SetSubsoundNULL();
FSBankLib.SUB_SOUND_FILE_PATHS("G:/u.wav");
FSBankLib.SUB_SOUND_OVER_RIDE_FLAG((int)FSBankLib.FSBANK_BUILDFLAGS.FSBANK_BUILD_DISABLESYNCPOINTS);
FSBankLib.SUB_SOUND_OVER_RIDE_QUALITY(1);
FSBankLib.SUB_SOUND_DESIRED_SAMPLE_RATE(0);
FSBankLib.SUB_SOUND_SAMPLE_NUMBER(1);
FSBankLib.FSB5_FSBANK_FORMAT((int)FSBankLib.FSBANK_FORMAT.FSBANK_FORMAT_VORBIS);
FSBankLib.FSBANK_RESULT result2 = (FSBankLib.FSBANK_RESULT)FSBankLib.FSBANK_BUILD(1,10,"G:/test");
Console.WriteLine(result2);