So I’ve been playing around for about 6 months in Monogame (when i’ve had spare time). I’ve created some nice 2d lighting that i’ve shared here and worked on a couple different projects / minigames. I’m currently in the process of playing with some audio.
There’s a few things in the audio portion that just dont seem complete. I got what I assume is trunk latest; and a few things (that I would give the opinion are needed) are missing. (Built my own libraries)
Song Duration
Song Looping
There’s nothing that’s stopping the engine from exposing these values, the work just isnt done (I think?)??? I give question marks cause I could totally be using this wrong.
…
Here’s what I did.
(Public / Private / Accessors / Modifiers changed throughout SoundEffect.cs Song.Default.cs)
In Song.Default.cs I made private void PlatformInitialize(string fileName)
contain
Duration = soundEffect.Duration;
which I set in SoundEffect FromStream
if (sfx.Format == OpenTK.Audio.OpenAL.ALFormat.Stereo16)
{
sfx.Duration = GetSampleDuration(sfx._data.Length, (int)sfx.Rate, AudioChannels.Stereo);
}
else if (sfx.Format == OpenTK.Audio.OpenAL.ALFormat.Mono16)
{
sfx.Duration = GetSampleDuration(sfx._data.Length, (int)sfx.Rate, AudioChannels.Mono);
}
My song now has a valid duration.
Song now has a
public bool Looping
{
get
{
return _sound.IsLooped;
}
set
{
_sound.IsLooped = value;
}
}
Section (_sound is public)
As long as you call Looping=true before you call play (Which on windows (and I assume linux) invokes the AL_Looping value your music will now loop.
Now I can just call this, and have infinite music playing:
m_oLevelsSong = SpriteManager.Instance.m_poContentManager.Load<Song>("BKGMusic/Destro/BattleTheme.wav");
m_oLevelsSong.Looping = true;
MediaPlayer.Play(m_oLevelsSong);
Is there another way around this, or is that pretty much the solution?