0
0

Hello all.

I have a strange issue that I cannot seem to track down. After a certain number of samples are played, suddenly the "global volume" for samples dives down to 0 within a second or so, and I cannot hear any more samples. I can play and hear new streams just fine (or rather, I can replay old streams and hence restart them), just not replay sound samples.

There’s no reference to volume changing currently inside my engine, and even if it was, it should affect streams as well. I don’t understand why it’d suddenly die, the code is still relativity simple. When I step through with a debugger, there are no errors or any issues at all.

Frankly I’m at a loss of what the issue could be now. Any suggestions?
I could try whip up some smaller sample code to post up, but I’m not sure there is even an issue with the code. However, there has to be? The only thing I can come up with is I somehow run out of virtual channels, but surely I’d get an error for that? Besides, the sound samples are only a second long or so. Even then, I tried setting the volume channel count up very high and it seems to cut out at the same rough time. If I play more sounds at once, the sound cuts out quicker.

//init. Yes, I realise its not the exact standard of creating the audio device, but since the device is already working… I do plan to get into this later on.
[code:2bo7a948]Logger.LogInfo("AudioEngine: Initializing...");
RESULT err;

err = FMOD.Factory.System_Create(ref sys);
if (err != RESULT.OK)
{
Logger.LogError("AudioEngine: Unable to init. Error Code: " + err);
Logger.LogError("AudioEngine: Selecting null output.");
return;
}

uint version = 0;
err = sys.getVersion(ref version);
if (err != RESULT.OK)
{
Logger.LogError("AudioEngine: Unable to obtain version of FMOD. Error Code: " + err);
Logger.LogError("AudioEngine: Selecting null output.");
sys.release();
sys = null;
return;
}

if (version < FMOD.VERSION.number)
{
Logger.LogError("AudioEngine: FMOD version is incompatible with this release. Please use version " + FMOD.VERSION.number + ". Error Code: " + err);
Logger.LogError("AudioEngine: Selecting null output.");
sys.release();
sys = null;
return;
}
Logger.LogInfo("AudioEngine: FMODEx SDK Version: " + FMOD.VERSION.number + " DLL Version: " + version);

//sys.setDriver() – use

//default quality
sys.setSoftwareFormat(48000, SOUND_FORMAT.PCM16, 0, 2, DSP_RESAMPLER.LINEAR);
//max quality
//sys.setSoftwareFormat(96000, SOUND_FORMAT.PCM24, 0, 2, DSP_RESAMPLER.SPLINE)
err = sys.init(200, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);[/code:2bo7a948]

//play sound
[code:2bo7a948]Channel channel = new Channel();
RESULT err = sys.playSound(CHANNELINDEX.FREE, Sound.soundData, false, ref channel.channel);[/code:2bo7a948]

//load sound
[code:2bo7a948]internal static Asset LoadSound(String Filename, SoundType Type)
{
if (sys == null)
return null;

    MODE soundMode = MODE.LOOP_OFF | MODE._2D | MODE.SOFTWARE | MODE.IGNORETAGS | MODE.VIRTUAL_PLAYFROMSTART;

    switch (Type)
    {
        case SoundType.Sample: soundMode |= MODE.CREATESAMPLE; break;
        case SoundType.Stream: soundMode |= MODE.CREATESTREAM; break;
    }

    FMOD.Sound fsound = new FMOD.Sound();
    RESULT err = sys.createSound(Filename, soundMode, ref fsound);
    if (err != RESULT.OK)
    {
        Logger.LogWarning(&quot;AudioEngine: Unable to load sound from file &quot; + Filename + &quot;. Error Code: &quot; + err + &quot; - &quot; + err.ToString());
        return null;
    }
    return new Sound() { soundData = fsound };
}[/code:2bo7a948]

//sound class
[code:2bo7a948]
public class Sound : Asset
{
public Channel Play()
{
return AudioEngine.Play(this);
}

public Channel CreateChannel()
{
    return AudioEngine.CreateChannel(this);
}
internal FMOD.Sound soundData;

}
[/code:2bo7a948]

  • You must to post comments
0
0

Are you calling fmod’s System.update?

  • You must to post comments
0
0

Durp. That was the issue. I thought you only had to call update if you were handleing things yourself. I don’t understand why the stream still worked either. In any case, I’ll have to have a closer look at system.update(). Thanks!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.