Exemplo n.º 1
0
        public Config GetConfig(ISoundLoader loader = null)
        {
            var config = new Config();

            config.Mixer = m_Mixer;
            if (loader == null)
            {
                config.BgmProvider    = m_Bgm.CreateProvider(null);
                config.GameSeProvider = m_GameSE.CreateProvider(null);
                config.UISEProvider   = m_UISE.CreateProvider(null);
                config.JingleProvider = m_JingleSE.CreateProvider(null);
                config.VoiceProvider  = m_VoiceSE.CreateProvider(null);
            }
            else
            {
                config.BgmProvider    = m_Bgm.CreateProvider(loader.LoadMusic);
                config.GameSeProvider = m_GameSE.CreateProvider(loader.LoadSound);
                config.UISEProvider   = m_UISE.CreateProvider(loader.LoadSound);
                config.JingleProvider = m_JingleSE.CreateProvider(loader.LoadSound);
                config.VoiceProvider  = m_VoiceSE.CreateProvider(loader.LoadVoice);
            }
            return(config);
        }
Exemplo n.º 2
0
        ISoundSource LoadSound(ISoundLoader[] loaders, IReadOnlyFileSystem fileSystem, string filename)
        {
            if (!fileSystem.Exists(filename))
            {
                Log.Write("sound", "LoadSound, file does not exist: {0}", filename);
                return null;
            }

            using (var stream = fileSystem.Open(filename))
            {
                ISoundFormat soundFormat;
                foreach (var loader in Game.ModData.SoundLoaders)
                {
                    stream.Position = 0;
                    if (loader.TryParseSound(stream, out soundFormat))
                        return soundEngine.AddSoundSourceFromMemory(
                            soundFormat.GetPCMInputStream().ReadAllBytes(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate);
                }
            }

            throw new InvalidDataException(filename + " is not a valid sound file!");
        }
Exemplo n.º 3
0
 public GameSoundPlayer(ISoundLoader loader, IGameStats gameStats)
 {
     _loader    = loader ?? throw new ArgumentNullException(nameof(loader));
     _gameStats = gameStats;
     _enabled   = true;
 }
Exemplo n.º 4
0
 public void Initialize(ISoundLoader[] loaders, IReadOnlyFileSystem fileSystem)
 {
     sounds = new Cache<string, ISoundSource>(s => LoadSound(loaders, fileSystem, s));
     currentSounds = new Dictionary<uint, ISound>();
     music = null;
     currentMusic = null;
     video = null;
 }
Exemplo n.º 5
0
 public SoundClipManager(ISoundLoader soundLoader, IConfiguration configuration, ILogger logger)
 {
     _soundLoader   = soundLoader;
     _configuration = configuration;
     _logger        = logger;
 }