5
\$\begingroup\$

*Solution:* I have a RealTek ALC888. I solved this (OpenAL) by disabling hardware acceleration on my sound (Control Panel > Sound > Advanced, disable acceleration).

I'm trying to integrate sound into my Monogame game. I don't have the content pipeline hack -- just straight Monogame (Beta 3) at this point.

(I tried adding the content pipeline, but ran into some issues.)

I added a .wav file to my /Content directory, and I can create and instantiate both SoundEffect and Song classes. However, both show durations of 00:00:00 (on a ten-second long file), and neither plays.

I can call LoadContent without any issue. But when I call Play, nothing plays.

I've tried a couple of different sounds, and different formats (MP3 and WAV) to rule that out. Only WAV seems to even load without crashing out, but it doesn't play.

This issue only occurs on Windows XP. I tested it on a Windows 7 laptop, and the sound plays fine.

Edit: I opened a MonoGame issue to track this, and it includes several more details.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Why don't you use plain XNA for the Windows builds of your game? \$\endgroup\$
    – r2d2rigo
    Dec 1, 2012 at 13:56
  • 1
    \$\begingroup\$ @r2d2rigo I don't trust that MS will support XNA moving forward. Monogame lets me run on Windows 8, plus I can include Android and iPhone once I buy the licenses. \$\endgroup\$
    – ashes999
    Dec 1, 2012 at 15:26
  • \$\begingroup\$ If the problem is fixed in 3.0... why not use 3.0? \$\endgroup\$ Dec 5, 2012 at 10:16
  • \$\begingroup\$ @JariKomppa sorry, I forgot to delete that. It's not fixed in 3.0, a different issue is. \$\endgroup\$
    – ashes999
    Dec 5, 2012 at 18:42
  • \$\begingroup\$ Was MonoGame compiled in Windows XP? Or are you just running what was compiled in Windows 7 in XP? If you haven't tried it already, compile MonoGame itself in Windows XP. \$\endgroup\$ Dec 6, 2012 at 18:07

1 Answer 1

1
\$\begingroup\$

It seems as though I am not the only one with problems getting MonoGame to run sounds on XP:

A very simple alternative is using SoundEffect SoundEffectInstance classes. It is incredibly easy to modify your Windows XACT code to use SoundEffect SoundEffectInstance, HOWEVER, I personally have had problems getting SoundEffect/SoundEffectInstance to work correctly under Windows XP where as XACT works just fine. So I decided to leave XACT on my Windows game and just use SoundEffect/SoundEffectInstance on Mac.

(Emphasis mine.) Based on this, I can safely assume that MonoGame/XP is broken for audio. Unfortunately, Steam's hardware survey frequently cites around 10% of their user-base uses XP. So it's vital to support it.

To make this work, I has a sad. I already have my game/framework code both split by platform (Windows and Android). I added NAudio to the Windows side, along with this lovely OGG player for NAudio.

To get my framework code to be uniform, I:

  • Created an interface on top of XNA's SoundEffect class
  • Created my own NAudioSoundEffect and XnaSoundEffect classes (former wraps NAudio, the latter wraps the XNA SoundEffect class)
  • Use Ninject to inject a factory by platform. It returns the correct sound effect class (XnaSoundEffect on all platforms except windows, which gets NAudioSoundEffect)

The solution allowed me to have a single AudioComponent class with an ISoundEffect instance, internally, which is platform-specific. And it works.

\$\endgroup\$
2
  • \$\begingroup\$ Have you considered sending a pull request to the MonoGame team? \$\endgroup\$ Feb 4, 2013 at 0:56
  • \$\begingroup\$ @VaughanHilts why would they be interested in my change? I put everything (eg. SpriteBatch, Texture2D) behind interfaces, wrote filler code, and did a bunch of other "major" changes they might not approve of. \$\endgroup\$
    – ashes999
    Feb 4, 2013 at 2:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .