[Solved] AccessViolationException in SoundEffectInstance.Apply3D(l, e)

I’m currently porting an XNA game to MonoGame and I’ll have to say that you Tom and all contributors can be proud with what you’ve achieved here. Awesome framework. Awesome people.
(Just recognizing as I’m typing… awesome board as well).

Nevertheless I have a problem that I’m just not able to tackle and I’m looking for someone to hopefully point out the bloody obvious to me since there has to be something I’m do wrong here.

The problem is as follows:
When calling Apply3D(AudioListener, AudioEmitter) on a SoundEffectInstance I always get a System.AccessViolationException in SharpDX.PlatformApply3D(AudioListener, AudioEmitter).

Imgur

I’m calling Apply3D from the main thread and it happens when playing a single SoundEffectInstance directly from the update-method of the game (tested that). So I don’t think it’s a threading problem, which I came across when researching the matter.
And I want to mention that all of this happens during normal game-execution, not when exiting.

Without Apply3D everything works like a charm. I’m playing loads of samples. No problem there.
But when I call Apply3D even once… Boom! Crash!

I’m using the latest version from the develop branch on a Windows 8.1 machine.
Could anyone please try to call SoundEffectInstance.Apply3D() in order to confirm this?
So what obvious thing am I missing here since I don’t think that I could be the only one with that problem?

Thanks in advance.

I ran into this problem myself today. What I have figured out so far is that it only happens for some sounds and not others. I found in my case switching the source file from stereo to mono prevented the crash, however, I’m now running into another case where the sound stops playing halfway through.

Thank you ahines57.
I will try encoding those sounds differently. Good point.

As for your problem with the sound stopping halfway through, I have had that problem myself about two weeks ago.
That is most definitely a problem caused when not using the MonoGame pipeline for the sound-files.
I remember re-encoding them and replacing the xnb files with the new ones and they played well again.
Hope that helps.

Thanks, glad we could help each other out, using pipeline.exe instead of the visual studio pipeline extensions solved that problem for me as well.

So. Like promised I’m back again.
@ahines57: You were right of course. The problem was that some of my effects where encoded in stereo (the wav-files) and I tried to apply them as 3D effect. That gave this ominous exception.
Since it was working perfectly in XNA I didn’t think of it as a possible source of error.

Maybe there is a way to catch that problem beforehand or to throw a more descriptive exception earlier on.
But everything’s fine now. 3D-soundEffects working like a charm.

Thanx.