From 0bc6b155127b0c03645947e2eec3574e0fc03029 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 16 Apr 2017 08:17:27 -0400 Subject: [PATCH] Document the audio manager --- ShiftOS_TheReturn/AudioManager.cs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 1dd2a8b..82b7000 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -43,6 +43,9 @@ namespace ShiftOS.Engine private static IAudioProvider _provider = null; private static bool _running = true; + /// + /// Stops the current sound if one is playing and disposes of the sound. + /// public static void Stop() { _out?.Stop(); @@ -50,17 +53,32 @@ namespace ShiftOS.Engine _out?.Dispose(); } + /// + /// Initiates this engine module using an as a backend for selecting background soundtrack as well as the volume level for the sound. + /// + /// A background soundtrack and volume provider. + /// Thrown if is null. public static void Init(IAudioProvider _p) { + if (_p == null) + throw new ArgumentNullException("_p"); _provider = _p; } + /// + /// Sets the volume of the audio system. + /// + /// The volume to use, from 0 to 1. public static void SetVolume(float volume) { _provider.Volume = volume; //persist between songs _out.Volume = volume; } + /// + /// Plays a specified sound file. + /// + /// The file to play. public static void Play(string file) { try @@ -74,6 +92,10 @@ namespace ShiftOS.Engine catch { } } + /// + /// Writes the data in the specified to a file, and plays it as a sound file. + /// + /// The stream to read from. public static void PlayStream(Stream str) { var bytes = new byte[str.Length]; @@ -86,14 +108,6 @@ namespace ShiftOS.Engine ShiftOS.Engine.AudioManager.Play("snd.wav"); } - - internal static void Kill() - { - _running = false; - _out.Stop(); - _out.Dispose(); - _reader.Dispose(); - } } public interface IAudioProvider