From 2bfbc16288454790f4c4cfa8ecace3518ee30059 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Fri, 15 Jun 2018 10:07:53 +0200 Subject: did Sound stuff --- DiscoBot/Audio/Sound.cs | 9 ++++++--- DiscoBot/Audio/Soundeffects.cs | 14 +++++++++++++- DiscoBot/Audio/Voice.cs | 10 ++-------- 3 files changed, 21 insertions(+), 12 deletions(-) (limited to 'DiscoBot') diff --git a/DiscoBot/Audio/Sound.cs b/DiscoBot/Audio/Sound.cs index 174c076..a9a2768 100644 --- a/DiscoBot/Audio/Sound.cs +++ b/DiscoBot/Audio/Sound.cs @@ -8,14 +8,17 @@ namespace DiscoBot.Audio { public class Sound { - public Sound(string name, string url) + public Sound(string name, string url, int volume) { - Name = name; - Url = url; + this.Name = name; + this.Url = url; + this.Volume = volume; } public string Name { get; } public string Url { get; } + + public int Volume { get; } } } diff --git a/DiscoBot/Audio/Soundeffects.cs b/DiscoBot/Audio/Soundeffects.cs index 317d0ff..d3e7cbb 100644 --- a/DiscoBot/Audio/Soundeffects.cs +++ b/DiscoBot/Audio/Soundeffects.cs @@ -1,9 +1,12 @@ namespace DiscoBot.Audio { using System; + using System.Linq; using System.Threading.Tasks; + using DiscoBot.Auxiliary; using DiscoBot.Commands; + using DiscoBot.DSA_Game; /*public enum Sound { @@ -27,7 +30,7 @@ { string url = string.Empty; int volume = 255; - switch (s) + /*switch (s) { case "Bell": case "Ding": @@ -59,6 +62,15 @@ url = "https://www.myinstants.com/media/sounds/wrong-answer-sound-effect.mp3"; volume = 50; break; + }*/ + + var tSound = Dsa.Properties.Sounds.OrderBy(x => SpellCorrect.CompareEasy(s, x.Name)).First(); + + url = s; + + if (SpellCorrect.CompareEasy(s, tSound.Name) > SpellCorrect.ErrorThreshold) + { + url = tSound.Url; } volume = (int)(volume * (Volume / 100.0)); diff --git a/DiscoBot/Audio/Voice.cs b/DiscoBot/Audio/Voice.cs index 5417560..daebed7 100644 --- a/DiscoBot/Audio/Voice.cs +++ b/DiscoBot/Audio/Voice.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using DiscoBot.Auxiliary; + using DiscoBot.DSA_Game; using Discord; using Discord.Audio; @@ -98,14 +99,7 @@ var sc = new SpellCorrect(); - var tSound = soundList.OrderBy(x => sc.Compare(path, x.ToString())).First(); - - if (sc.Compare(path, tSound.ToString()) > SpellCorrect.ErrorThreshold) - { - await Task.Run(() => Voice.Send(path)); - } - - await Task.Run(() => SoundEffects.Play(path)); + } private static Process CreateStream(string path, int vol = 256) -- cgit v1.2.3-70-g09d2