Song cutting off prematurely

Basically, I’m loading a song into MonoGame, and it seems to accept it (.ogg files, at least. Didn’t like .mp3s)
The problem is, when I use MediaPlayer.Play(song) it cuts off about a second before it should, leading to imperfect looping.
Is this a MonoGame bug, or am I doing something wrong?

Hang in there!
I play music in some of my stuff, so It can work.
I have had various problems that had to be fixed first though…

Have you verified that your song plays as intended in an mp3 player?
-Your problem may be caused by a conversion/export setting in your editing software… It may be set to cut off right after the last note, and not render the remainder of the last measure…

Yeah, it plays fine in an external player, strangely.
I’m wondering if there’s some sort of extra/missing data somewhere in the .ogg file, as I used Audacity to convert from .mp3 to .ogg for MonoGame purposes.

ALSO, I have seen a post on looping before, and learned THIS:
mp3s dont end based on the actual song. The end at fixed intervals… So for looping, there is likely to be a certain gap between play-backs… You would have to program the player to account for this…

1 Like

One workaround/fix for this, might be to insert a second of silence (or extremely low volume sound) at the end… But again, I play music (though its not .ogg) and once it works, it works as expected…

1 Like

Just tested without looping:
It’s still cutting off. Even when I just tell it to play the intro for the song (I cut my song into intro and loop, play the intro first, then loop the loop part), it cuts off a second or so before the end.

I’m a total noob when it comes to sound programming, so I have no idea how to do this.

This however, I might be able to do!

this ogg, is it a mac format or?

Sorry I think you said you have, but does it work on a native media player in loop mode, no problems?

.ogg is a Vorbis format, commonly used because of its portability and decent compression algorithms.

Yes, it works perfectly in a native media player.

I am not familiar with it too much yet playing music in MonoGame.

If you break during program and inspect the song object you are playing, does it have a total time and does it match the original ogg file?

Yes, and yes. When I make it break as it ends the song, it says the MediaPlayer.PlayPosition is correct (12.8s in this case for the intro).

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?