diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 5ed79a37f0..9219b2fe47 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -4,7 +4,8 @@ using OpenRa.Game.Graphics; using OpenRa.TechTree; using System.Drawing; using System.Linq; -using IrrKlang; +using IrrKlang; +using IjwFramework.Collections; namespace OpenRa.Game { @@ -57,20 +58,32 @@ namespace OpenRa.Game controller = new Controller(this); // CAREFUL THERES AN UGLY HIDDEN DEPENDENCY HERE STILL worldRenderer = new WorldRenderer(renderer, this); - var sound = AudLoader.LoadSound(FileSystem.Open("intro.aud")); - soundEngine = new ISoundEngine(); - - var soundSource = soundEngine.AddSoundSourceFromPCMData(sound, "intro.aud", + sounds = new Cache(LoadSound); + + PlaySound("intro.aud", false); + } + + readonly Cache sounds; + + ISoundSource LoadSound(string filename) + { + var data = AudLoader.LoadSound(FileSystem.Open(filename)); + return soundEngine.AddSoundSourceFromPCMData(data, filename, new AudioFormat() { ChannelCount = 1, - FrameCount = sound.Length / 2, + FrameCount = data.Length / 2, Format = SampleFormat.Signed16Bit, SampleRate = 22050 }); + } - soundEngine.Play2D(soundSource, true, false, true); + public void PlaySound(string name, bool loop) + { + var sound = sounds[name]; + // todo: positioning + soundEngine.Play2D(sound, loop, false, false); } public void Tick() diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index 709c7de954..ade6d7b94d 100644 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -30,7 +30,9 @@ namespace OpenRa.Game FileSystem.Mount(new Package("conquer.mix")); FileSystem.Mount(new Package("hires.mix")); FileSystem.Mount(new Package("general.mix")); - FileSystem.Mount(new Package("local.mix")); + FileSystem.Mount(new Package("local.mix")); + FileSystem.Mount(new Package("sounds.mix")); + FileSystem.Mount(new Package("speech.mix")); FormBorderStyle = FormBorderStyle.None; BackColor = Color.Black;