Given a DLL that's supposed to play SNES SPC files and FMOD, in C#, why does this call to system.createSound
fail?
var ret = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
var soundEx = new FMOD.CREATESOUNDEXINFO()
{
cbsize = Marshal.SizeOf(soundEx),
fileoffset = 0,
length = ~0U,
numchannels = 2,
defaultfrequency = 32000,
format = FMOD.SOUND_FORMAT.PCM16,
pcmreadcallback = pcmreadcallback,
pcmsetposcallback = pcmsetposcallback,
dlsname = null,
};
var mode = FMOD.MODE.DEFAULT | FMOD.MODE.OPENUSER
| FMOD.MODE.LOOP_NORMAL | FMOD.MODE.CREATESTREAM;
ret = system.createSound((string)null, mode, ref soundEx, ref sound);
//^-- ERR_INVALID_PARAM
ret = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
Compare that with the usercreatedsound
sample that comes with FMOD:
FMOD.MODE mode = (FMOD.MODE._2D | FMOD.MODE.DEFAULT
| FMOD.MODE.OPENUSER | FMOD.MODE.LOOP_NORMAL
| FMOD.MODE.HARDWARE);
//snip
createsoundexinfo.cbsize = Marshal.SizeOf(createsoundexinfo);
createsoundexinfo.fileoffset = 0;
createsoundexinfo.length = frequency * channels * 2 * 2;
createsoundexinfo.numchannels = (int)channels;
createsoundexinfo.defaultfrequency = (int)frequency;
createsoundexinfo.format = FMOD.SOUND_FORMAT.PCM16;
createsoundexinfo.pcmreadcallback = pcmreadcallback;
createsoundexinfo.pcmsetposcallback = pcmsetposcallback;
createsoundexinfo.dlsname = null;
//snop
result = system.createSound(
(string)null,
(mode | FMOD.MODE.CREATESTREAM),
ref createsoundexinfo,
ref sound);
Length, frequency... doesn't matter.
Edit: I've already confirmed that the SPC player works, at least as far as initialization goes, and the sample that came with FMOD builds and runs just fine. The only particularly meaningful change, aside from twiddling the settings in an attempt to get it to run, is writing it in 4.0 style.