Song cutting off prematurely

Just throwing it out there, one thing you could do, was use an alternate format- Just to trouble shoot if the issue lies with the format… Because I know the format I use works without issue…

What format do you use? Because I had trouble getting .mp3 to load at all. I kept getting a “Cannot determine container type” exception, or something similar to that.

Yeah, you have to use the pipeline tool for the mp3s… It comes with monogame.

It takes an MP3 file, and generates 2 files that monogame uses… I think one is a pointer file, and the other is content…
They have the same name, but extensions are xnb and wma…

you just drag and drop them into the solution explorer, to replace your old ogg file of the same name.
And set them both to “content, copy if newer”.

…Assuming your platform works like mine, which is all I know…

The MonoGame content pipeline can do the conversion to Ogg Vorbis when the Platform is DesktopGL.

Ogg is a container file format. Vorbis is the audio compression codec. Theora is the video compression codec, which uses Vorbis for the audio streams.

This only becomes an issue when playing MP3s. Converting MP3 to Ogg Vorbis shouldn’t suffer from this. Ideally you should be converting to a compressed format from the original uncompressed 16-bit PCM WAV. This avoids any issues with converting from one lossy compressed format to another lossy compressed format.

Thanks for the reply!
I’m using DesktopGL for my project, as I am targeting Windows, Mac and Linux.

I can’t convert from the original WAV, unfortunately, as I am not the producer of the piece, I only received an mp3, which I converted to ogg (both of which work fine in native players).
Do you have any idea why I am running into this issue with my oggs?

Are you loading them into the project via VS or are you building through content pipeline?

I’ve tried doing both, and it doesn’t make a difference whether I use Song.FromUri or Content.Load().

will you try converting the MP3 into xnb and wma instead of ogg…?

-maybe that could pin-point the issue, and maybe it could work.

I think thats all I can do to help… Good luck!

This did not help, unfortunately. Still the same issue.

EDIT:
Just to bring it up; I’m using MonoGame 3.5, trying to compile for DesktopGL.
Is it perhaps worth raising an issue?

hmm… Unfortunately, I have always used the other template, never the openGL, so I cant be of any further help. :frowning:

1 Like

I appreciate the help, anyway! Thank you!

Have you got your project up on github or anywhere, or can you share specific parts of code we can run?

I do indeed. Let me make it public so you can clone it. Give me a few hours though, as I’m not at home.

Sorry for the double post, just going to dump this link to my repo here:
https://bitbucket.org/nosrick/joy

I have this exact same issue. Did you ever get this working properly? Or did you resort to adding the right amount of silence to the end of your track?

So yup, my solution was just to add 1 second of silence to the end of the track in Audacity. It does the trick so I guess it doesn’t matter, but it seems like the hackish solution and surely there’s an explanaition to why it’s happening to us and not others.

Info:
I’m developing on Linux, building for DesktopGL, and using the content pipeline to import the original .wav file as a song.
Development build of monogame.
Development build of monogame.extended (if for some reason that would matter…)

Sorry for bumping this, but I’m having the exact same issue and I haven’t been able to find anything else on this. Using MonoGame 3.7.0.678. (latest build available on the website). I’m developing on Windows 10 and created the project with the cross platform desktop template (OpenGL).

I’m loading and playing ogg music files like so:

var song = content.Load<Song>("ogg/" + name);
MediaPlayer.Play(song);

The music cuts off about a second too soon on every clip I’ve tried. As a last resort I’ll use Romans_I_XVI’s solution, but it seems pretty hacky and I’d prefer a cleaner solution.

I’ve found an acceptable workaround until this is fixed:

In the content pipeline, convert all the music files from Song to SoundEffect. Then load music as a SoundEffect, create a SoundEffectInstance from it, and play it that way.

SoundEffect backgroundMusic = content.Load<SoundEffect>("ogg/" + name);
currentMusicInstance = backgroundMusic.CreateInstance();
currentMusicInstance.IsLooped = true;
currentMusicInstance.Volume = 0.1f;
currentMusicInstance.Play();

Using this method, the entire track plays and loops flawlessly. The downside is that this tripled the size of my project (~50 MB to ~150 MB) since the music files are no longer compressed ogg files.

This was fixed here: https://github.com/MonoGame/MonoGame/pull/5821

You either have to compile MonoGame yourself or wait until 3.7 is released. I’ve tested it also with FNA and there it worked without a problem.

Great news, thanks for the heads up.

I installed the latest development build from the website (3.7.0.849) and tested it on my Windows 10 machine and it’s definitely better, but the loops still aren’t as flawless as simply playing a SoundEffect on loop. Some tracks have a short delay between loops, and some are still looping maybe a half second too soon. I’ll test on my Mac later on and see if it’s the same.