Simple way to use .OGG bg music and .OGG sound effects ?

Do you mean you want to read an ogg file directly without using the content pipeline ? Because if you are new to programming, the pipeline is the simplest way to do it. Otherwise you wil’ have to use an external library and it will likely be more complex.

Basically, I want to use background music (song) without ending up with a .WMA file in the distributable version of the game. .WAV is too big, .MP3 is licensed, so .OGG seems to be the only alternative.

So yes, this probably means not using the Content Pipeline. That’s why I’m asking for help here… I wouldn’t bother you all if it were ‘simple’ to do or to google. :wink:

DesktopGL uses OGG as its native music streaming format. Using OGG for sound effects natively is not supported in MonoGame at this time, mainly because there could be many tens of sound effects playing at any one time, and each of those are usually short in duration. Decoding multiple OGG sounds at once could be computationally too expensive.

Ok, forget the sound thing… what about just playing background music?

What exactly is DesktopGL? I thought MonoGame was an alternative to using OpenGL, and now I have to use GL again, just for sound?

Please explain (newbie, remember?) :wink:

Can you not just build the ogg files as resources in your project?

(Then do you need a player class, are there different ones for openGL and DirectX?)

MonoGame uses a graphics API. On Windows it uses DirectX or OpenGL, depending on which version of MonoGame you reference. The DirectX version uses Windows Media Foundation, which does not support OGG. The DesktopGL version has code to support playback of OGG streaming music.

Ah, ok… then just one last question:

As it seems, I’ve installed the Monogame ‘DirectX’ version. Where exactly can I get the DesktopGL version, and how do I uninstall the MonoGame DirectX and replace it with the DesktopGL version? Or can I install and use them parallel?

And after the switch, can I then play .OGG like Load[Song], or will it still be converted?

All versions are installed, you just switch to which type (dx, or opengl) you want when creating the project under the IDE.

I think some people have a solution containing many projects, with each project targeting different platforms.

@Alkher:

Um… ok, then for a test, I would like to create a game that does NOT depend on Windows Media Foundation and uses a native .OGG file for background music, but still plays on Windows systems.

Where exactly do I switch the project? (Ive already selected 'MonoGame Windows Project, am I bound to it now?)

Newbie, please step-by-step…

I think create a new OpenGL project and copy everything across?

Might be a way to clone a project under a new template?

It might just entirely be one line, look at properties of your project file and conditional compiliation symbols in Build.

It can either be WINDOWS, LINUX etc.

Hm… it ‘might’? You mean I can’t create a Windows game that does not depend on Windows Media Foundation and uses .OGG? I have to select a specific system, and depending on that MonoGame chooses what to use?

Not 100% sure but it sounds like

DirectX project = using WMF
OpenGL project = using ogg (and others?)

Would be interesting to find out how to do a DirectX project but still use the “openGL” variants of media etc.

(If you go through monogame source code you will see a lot of #if WINDOWS etc wrapping certain parts, so if using windows you might be stuck with directX and WMF)

So, what this seems to come down to - nobody can tell me a simple way to use native .OGG files in a Windows game?!

the content pipeline converts fbx to xnb, converts textures to a proper format and converts sound to a better format for gaming.

Why would you need to have an .ogg file in the output binary folder? Just curious.

Well, it would be nice to have just one format for all platforms…

… can .WMA be used freely in games? Or do people have to pay a fee to Microsoft?

Start a DesktopGL project and add your ogg to the content pipeline, then load it like kosmonaut said. If you already have a DX project, switch the MonoGame.Framework.Windows reference to MonoGame.Framework.WindowsGL, change the pipeline tool target platform and fix output directories first. An ogg processed for OpenGL is still really an ogg internally I think. The pipeline tool picks appropriate formats for content depending on the platorm you’re targeting. If you’re only targeting windows, switching to OpenGL just to get ogg files is not something i’d recommend…

Ok, sounds doable… will try that. :wink:

Thanks to everyone for the help, and the insights.

BTW, can .WMA be used freely for Windows projects, or do programmers have to pay a fee to Microsoft?

You can use it freely!

BTW, can .WMA be used freely for Windows projects, or do programmers have to pay a fee to Microsoft?

Our content pipeline only supports producing unencumbered formats. This means we produce WMA, M4A or OGG because there are no licensing requirements for distributing files in those formats. This is why we do not produce MP3 files. If a developer wants to use MP3, that is their choice, but we will not help a developer to violate licensing by producing files in those formats.

2 Likes