Exemplo n.º 1
0
        public void LoadSound(string name)
        {
            if (loadedSounds.ContainsKey(name))
            {
                return;
            }
            if (loadedSounds.Count == 64)
            {
                var toRemove = soundQueue.Dequeue();
                toRemove.Data.Dispose();
                loadedSounds.Remove(toRemove.Name);
            }
            var loaded = new LoadedSound();

            loaded.Entry = data.GetAudioEntry(name);
            loaded.Name  = name;
            if (loaded.Entry.File.ToLowerInvariant().Replace('\\', '/') == "audio/null.wav")
            {
                //HACK: Don't bother with sounds using null.wav, makes awful popping noise
                loaded.Data = null;
            }
            else
            {
                var path = data.GetAudioPath(name);
                var snd  = audio.AllocateData();
                snd.LoadFile(path);
                loaded.Data = snd;
            }
            soundQueue.Enqueue(loaded);
            loadedSounds.Add(name, loaded);
        }
 public Data.Audio.AudioEntry GetEntry(string name) => data.GetAudioEntry(name);