From 11f838ea2340b50a7899cf9fb2569b0826aef001 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 29 Jan 2017 12:11:31 -0500 Subject: [PATCH] Add audio.setvol command for setting track volume --- ShiftOS_TheReturn/AudioManager.cs | 6 +++++- ShiftOS_TheReturn/Commands.cs | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index d133f07..7d01a52 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -51,7 +51,11 @@ namespace ShiftOS.Engine t.Start(); } - + public static void SetVolume(float volume) + { + _provider.Volume = volume; //persist between songs + _out.Volume = volume; + } } public interface IAudioProvider diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 64cb72a..bfcdb7e 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -44,6 +44,20 @@ using ShiftOS.Objects.ShiftFS; namespace ShiftOS.Engine { + [Namespace("audio")] + public static class AudioCommands + { + [Command("setvol", description = "Set the volume of the system audio to anywhere between 0 and 100.")] + [RequiresArgument("value")] + public static bool SetVolume(Dictionary args) + { + int val = Convert.ToInt32(args["value"].ToString()); + float volume = (val / 100F); + AudioManager.SetVolume(volume); + return true; + } + } + [RequiresUpgrade("mud_fundamentals")] [Namespace("mud")] public static class MUDCommands