I’m loading about 30 16-bit samples, raw, from memory, and applying known loop points to them. The following C# code snippet is an example of how I’m loading the samples:
FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
exinfo.format = FMOD.SOUND_FORMAT.PCM16;
exinfo.numchannels = 1;
exinfo.defaultfrequency = 11025;
loopendpoint = thedata2.Length/2 – 1;
uint l1 = (uint)(looppoint);
uint l2 = (uint)(loopendpoint);
exinfo.length = (uint)thedata2.Length / 2;
exinfo.cbsize = System.Runtime.InteropServices.Marshal.SizeOf(exinfo);
//create looped or unlooped sample
if (l2 > l1)
result = Form1.system.createSound(thedata2, (FMOD.MODE.SOFTWARE | FMOD.MODE.OPENMEMORY | FMOD.MODE.OPENRAW | FMOD.MODE.LOOP_NORMAL), ref exinfo, ref sample);
result = Form1.system.createSound(thedata2, (FMOD.MODE.SOFTWARE | FMOD.MODE.OPENMEMORY | FMOD.MODE.OPENRAW), ref exinfo, ref sample);
//Set loop points FMOD.RESULT res; res = sample.setLoopPoints(l1, FMOD.TIMEUNIT.PCMBYTES, l2, FMOD.TIMEUNIT.PCMBYTES);
"thedata2" is an array of bytes holding little-endian 16-bit short data values for the waveform
"looppoint" is a known loop-begin point (loaded from a set of data for which I had this working in an old FMOD version), units being 16-bit samples (2 bytes)
"loopendpoint" is calculated as the last 16-bit value in the thedata2 array
"sample" is a previously-declared FMOD.SOUND object, that I’m using when I play the sound.
Now, this turns out sounding alright for some samples, but not for others. Some samples’ loops include a buzzing sound, as if they include extra corrupted data, yet the rest of the sample, or the sample played without looping, sounds fine.
I have examined the values in the loop points and the "thedata2" array, and for the samples that do not sound correct, the data looks as if it should loop smoothly–ie, the values at the beginning and end of the loop are similar, sloping similarly, etc. There is no extra or corrupted data as the resulting sound would suggest. They are all very small samples (MOD-like), so the data is fairly easy to examine.
I’ve picked through the docs for any reason that PCMBYTES and LOOP_NORMAL wouldn’t function correctly together for 16 bit samples, and can’t seem to find anything. Setlooppoints is returning "OK" for all of them, as is createSound. Any ideas?
- Mop asked 11 years ago
Whether or not this helps, I grabbed some data from MSVS’s debugger on one of the samples that doesn’t sound right:
The data from one loop to the next appears to be smooth, and should have a nice sine-wave-ish sound to it (it’s a bass sample). However the sound produced after the loop begins is a much sharper sound–as if the transition between the two points had not been made smoothly.
For any of you interested, I decided to drop Fmod EX and access the old Fmod 184.108.40.206 DLL manually, under which sample-specific loop points actually function correctly, and my SNES audio player works as it used to.
While I would have preferred to use the newer, more updated version of the software, I can’t sit around for months waiting for what seems to be a simple bug fix to an ancient feature to get even a second glance from anyone on the FMOD staff.
Oh well; problem solved, though not the way I would have appreciated.
Please login first to submit.