Skip to content

Commit

Permalink
Added AudioManager.Play(SoundEffectInstance) which plays using the ma…
Browse files Browse the repository at this point in the history
…ster volume
  • Loading branch information
vchelaru committed Jan 1, 2024
1 parent 10766fd commit 1a0fd3a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
25 changes: 24 additions & 1 deletion Engines/FlatRedBallXNA/FlatRedBall/Audio/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public static void Play(SoundEffect soundEffect, float volume, float pitch = 0,
}
#endif
///////////////////Early Out////////////////////////////////
if(!AreSongsEnabled || ScreenManager.IsInEditMode)
if(!AreSoundEffectsEnabled || ScreenManager.IsInEditMode)
{
return;
}
Expand Down Expand Up @@ -692,6 +692,29 @@ public static int GetNumberOfTimesCurrentlyPlaying(SoundEffect soundEffect) =>
mSoundEffectPlayInfos.Count(item => item.SoundEffect == soundEffect);
#endregion

#region SoundEffectInstance

public static void Play(SoundEffectInstance soundEffectInstance)
{
///////////////////Early Out////////////////////////////////
if (!AreSoundEffectsEnabled || ScreenManager.IsInEditMode)
{
return;
}
///////////////End Early Out////////////////////////////////

//bool shouldPlay = SoundEffectPlayingBehavior == Audio.SoundEffectPlayingBehavior.PlayAlways ||
//
// mSoundsPlayedThisFrame.Contains(soundEffectInstance.Name) == false;

soundEffectInstance.Volume = MasterSoundVolume;
soundEffectInstance.Play();

// todo - store information about max sound effects playing?
}

#endregion

#region Manager methods


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ internal void PlaySound()
catch(Exception e)
{
GlueCommands.Self.PrintError(Localization.Texts.ErrorPlayingWavFile + "\n" + e);
GlueCommands.Self.DialogCommands.FocusTab(Localization.Texts.Output);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public ContentPipelineMismatchViewModel(ReferencedFileSave rfsUsingContentPipeli
this.rfsUsingContentPipeline = rfsUsingContentPipeline;

this.Details = "The two files " + rfsUsingContentPipeline + " and " + rfsNotUsingContentPipeline +
" have the same file name but one is using the content pipeline and the other is not. This can cause runtime errors.";
$" have the same file name.\n{rfsUsingContentPipeline} is using the content pipeline." +
$"\n{rfsNotUsingContentPipeline} is not." +
$"\nThis can cause runtime errors.";
}

public override void HandleDoubleClick()
Expand Down

0 comments on commit 1a0fd3a

Please sign in to comment.