Thanks for the reply, yeah I probably should’ve included a code example to begin with.
Not sure on the right way to get the FMod version number, but the version I get from getversion() is 131622.
To preface the code, there are two things stored elsewhere:
1 - _FMod_System is the FMod.System I’ve created
2 - State is simply a RESULT for sotring error results
The function I’ve created is intended to (eventually) load a sound, extract the data needed to recreate it and pass back that all out to.
I’ve included the screenshot from Mediainfo below, though there isn’t much to it.
I notice you mentioned OPEN_RAW ‘or’ OPEN_USER, I’m actually using both as I thought they were both needed, should I be using only one?
Regarding the CREATESOUNDEXINFO.format, I’m using getFormat from the loaded sound to get both the SOUND_TYPE and SOUND_FORMAT and passing those into CREATESOUNDEXINFO.
The key thing I can say is, if I change the MODE.OPENONLY to MODE.DEFAULT and return that sound instead, it plays fine.
Here’s the code:
public static byte[] Load_Sound_Data(string File_Name, out Sound New_Sound, out CREATESOUNDEXINFO Sound_Data)
{
State = _FMod_System.createSound(File_Name, MODE.OPENONLY, out Sound T_Sound);
if (State != RESULT.OK) { System.Console.WriteLine("File could not be loaded: " + State); State = RESULT.OK; New_Sound = new(); Sound_Data = new(); return null; }
_ = T_Sound.getLength(out uint Length, TIMEUNIT.PCMBYTES);
byte[] Data = new byte[Length];
_ = T_Sound.readData(Data);
_ = T_Sound.getDefaults(out float Frequency, out _);
_ = T_Sound.getFormat(out SOUND_TYPE Sound_Type, out SOUND_FORMAT Sound_Format, out int Channels, out _);
_ = T_Sound.release();
unsafe
{
Sound_Data = new()
{
length = Length,
cbsize = sizeof(CREATESOUNDEXINFO),
numchannels = Channels,
defaultfrequency = (int)Frequency,
format = Sound_Format,
suggestedsoundtype = Sound_Type,
};
}
_ = _FMod_System.createSound(Data, MODE.OPENMEMORY | MODE.OPENRAW | MODE.CREATESAMPLE | MODE._2D | MODE.LOOP_OFF | MODE.OPENUSER, ref Sound_Data, out New_Sound);
return Data;
}