diff --git a/RhythmBullet/RhythmBullet.csproj b/RhythmBullet/RhythmBullet.csproj index de70da7..ee806ae 100644 --- a/RhythmBullet/RhythmBullet.csproj +++ b/RhythmBullet/RhythmBullet.csproj @@ -47,6 +47,9 @@ true + + + @@ -85,12 +88,12 @@ ..\packages\BulletSharp.0.11.1\lib\net40-client\BulletSharp.dll - - ..\packages\DSP.1.0.0\lib\DSP.dll - $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\DesktopGL\MonoGame.Framework.dll + + ..\packages\NAudio.1.8.5\lib\net35\NAudio.dll + @@ -147,7 +150,9 @@ - + + + diff --git a/RhythmBullet/Zer01HD/Audio/MusicController.cs b/RhythmBullet/Zer01HD/Audio/MusicController.cs new file mode 100644 index 0000000..e3f00d3 --- /dev/null +++ b/RhythmBullet/Zer01HD/Audio/MusicController.cs @@ -0,0 +1,26 @@ +using Microsoft.Xna.Framework.Media; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RhythmBullet.Zer01HD.Audio +{ + internal class MusicController + { + MusicList musicList; + + public MusicController(MusicList musicList) + { + this.musicList = musicList; + } + + public void LoadMusic(string path) + { + + } + + + } +} diff --git a/RhythmBullet/Zer01HD/Audio/MusicList.cs b/RhythmBullet/Zer01HD/Audio/MusicList.cs new file mode 100644 index 0000000..0f94897 --- /dev/null +++ b/RhythmBullet/Zer01HD/Audio/MusicList.cs @@ -0,0 +1,93 @@ +using Microsoft.Xna.Framework.Media; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace RhythmBullet.Zer01HD.Audio +{ + internal class MusicList + { + private volatile bool work; + private List list = new List(); + public List List + { + get + { + if (!thread.IsAlive) + { + lock (list) + { + return list; + } + } + else + { + return null; + } + } + } + private string path; + private Thread thread; + + public MusicList() + { + + } + + public void Start() + { + if (thread == null || !thread.IsAlive) + { + work = true; + thread = new Thread(Search); + thread.Name = "Music Search Thread"; + thread.Start(); + } + } + + public void Stop() + { + work = false; + } + + private void Search() + { + lock (list) + { + list.AddRange(recursiveMusicSearch(path)); + } + } + + private List recursiveMusicSearch(string path) + { + List musicFiles = new List(); + string[] files = Directory.GetFiles(path); + for (int i = 0; i < files.Length && work; i++) + { + if (Directory.Exists(files[i])) + { + musicFiles.AddRange(recursiveMusicSearch(files[i])); + } + else + { + try + { + SupportedFormats format; + Enum.TryParse(Path.GetExtension(files[i]).ToUpper(), out format); + musicFiles.Add(files[i]); + } + catch (ArgumentException e) + { + Console.WriteLine("MusicList", "Unsupported file format: " + Path.GetFileName(files[i])); + Console.WriteLine(e); + } + } + } + return musicFiles; + } + } +} diff --git a/RhythmBullet/Zer01HD/Audio/SupportedFormats.cs b/RhythmBullet/Zer01HD/Audio/SupportedFormats.cs new file mode 100644 index 0000000..d18944d --- /dev/null +++ b/RhythmBullet/Zer01HD/Audio/SupportedFormats.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RhythmBullet.Zer01HD.Audio +{ + public enum SupportedFormats + { + WAV, MP3 + } +} diff --git a/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentManagerController.cs b/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentManagerController.cs index 14ac617..b83e28c 100644 --- a/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentManagerController.cs +++ b/RhythmBullet/Zer01HD/Utilities/ContentSystem/ContentManagerController.cs @@ -74,8 +74,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem { if (queue.Count > 0 && (thread == null || !thread.IsAlive)) { - ThreadStart threadStart = new ThreadStart(LoadBatch); - thread = new Thread(threadStart); + thread = new Thread(LoadBatch); thread.Start(); } } diff --git a/RhythmBullet/packages.config b/RhythmBullet/packages.config index 12407c1..cdd1fe9 100644 --- a/RhythmBullet/packages.config +++ b/RhythmBullet/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file