Change the speed at which audio loaded without the content manager plays

I’m looking to load a song from a file whose location isn’t known at build time and play it at a certain speed.

The two classes for loading and playing sounds, Song and SoundEffect, seem to only be capable of one of those things each:

  • Song instances can be loaded using Song.FromUri, but I can’t seem to find a way to set the speed at which that song plays.
  • SoundEffect instances seem to have a way to configure playback speed by setting pitch, but I couldn’t find a method like SoundEffect.FromUri.

What is the recommended way to go about this?

I’ve seen ppl mention it’s possible to load into a SoundEffect(or DynamicSoundEffectInstance) using theora (OGG), c# mp3 decoder lib, or FMOD so that you can load the file from a chosen location at runtime and set a decoder sample rate (I’m assuming this changes playback speed) and so then you put it into a memory stream and get it from that.
If I remember correctly, you create a memory stream and using that with a binary writer, you can use
music = SoundEffect.FromStream(my_music_stream);
I know I found a page on this somewhere - I can see if I can find it again if this is what you’re after.

I’m not sure this solves your problem but I found the Monogame sound system lacking so I’m using DirectX to stream in OGG files (Windows and Linux only). Here’s a link to the blog with source code.

http://hernblog.com/blogs/replacingMonogameSongsWithDirectX.html

1 Like