public void StopBGM(int channel)
        {
            AudioLayer audioLayer = channelDictionary[channel];

            audioLayer.StopAudio();
            if (currentAudio[AudioType.BGM].ContainsKey(channel))
            {
                currentAudio[AudioType.BGM].Remove(channel);
            }
        }
        public void StopVoice(int channel)
        {
            AudioLayer audioLayer = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            audioLayer.StopAudio();
            if (currentAudio[AudioType.Voice].ContainsKey(channel))
            {
                currentAudio[AudioType.Voice].Remove(channel);
            }
        }
        public void PlaySE(string filename, int channel, float volume, float pan)
        {
            AudioLayer audioLayer = channelDictionary[GetChannelByTypeChannel(AudioType.SE, channel)];

            if (audioLayer.IsPlaying())
            {
                audioLayer.StopAudio();
            }
            audioLayer.PlayAudio(filename, AudioType.SE, volume);
        }
 public void StopAllVoice()
 {
     for (int i = 0; i < 8; i++)
     {
         AudioLayer audioLayer = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, i)];
         if (audioLayer.IsPlaying())
         {
             audioLayer.StopAudio();
         }
     }
 }
        public void FadeOutSE(int channel, float time, bool waitForFade)
        {
            float      num = time / 1000f;
            int        channelByTypeChannel = GetChannelByTypeChannel(AudioType.SE, channel);
            AudioLayer audioLayer           = channelDictionary[channelByTypeChannel];

            audioLayer.FadeOut(num);
            if (waitForFade)
            {
                GameSystem.Instance.AddWait(new Wait(num, WaitTypes.WaitForAudio, audioLayer.StopAudio));
            }
        }
        public AudioController()
        {
            GameSystem.Instance.AudioController = this;
            currentAudio.Add(AudioType.BGM, new Dictionary <int, AudioInfo>());
            currentAudio.Add(AudioType.Voice, new Dictionary <int, AudioInfo>());
            audioParent = new GameObject("AudioLayers");
            int num = 0;

            for (int i = 0; i < 6; i++)
            {
                GameObject gameObject = new GameObject("BGM Channel " + i.ToString("D2"));
                AudioLayer audioLayer = gameObject.AddComponent <AudioLayer>();
                gameObject.transform.parent = audioParent.transform;
                audioLayer.Prepare(num);
                channelDictionary.Add(num, audioLayer);
                num++;
            }
            for (int j = 0; j < 8; j++)
            {
                GameObject gameObject2 = new GameObject("Voice Channel " + j.ToString("D2"));
                AudioLayer audioLayer2 = gameObject2.AddComponent <AudioLayer>();
                gameObject2.transform.parent = audioParent.transform;
                audioLayer2.Prepare(num);
                channelDictionary.Add(num, audioLayer2);
                num++;
            }
            for (int k = 0; k < 8; k++)
            {
                GameObject gameObject3 = new GameObject("SE Channel " + k.ToString("D2"));
                AudioLayer audioLayer3 = gameObject3.AddComponent <AudioLayer>();
                gameObject3.transform.parent = audioParent.transform;
                audioLayer3.Prepare(num);
                channelDictionary.Add(num, audioLayer3);
                num++;
            }
            for (int l = 0; l < 2; l++)
            {
                GameObject gameObject4 = new GameObject("System Channel " + l.ToString("D2"));
                AudioLayer audioLayer4 = gameObject4.AddComponent <AudioLayer>();
                gameObject4.transform.parent = audioParent.transform;
                audioLayer4.Prepare(num);
                channelDictionary.Add(num, audioLayer4);
                num++;
            }
            AudioConfiguration configuration = AudioSettings.GetConfiguration();

            configuration.sampleRate = 44100;
            AudioSettings.Reset(configuration);
        }
        public void FadeOutBGM(int channel, int time, bool waitForFade)
        {
            float      num = (float)time / 1000f;
            int        channelByTypeChannel = GetChannelByTypeChannel(AudioType.BGM, channel);
            AudioLayer audioLayer           = channelDictionary[channelByTypeChannel];

            audioLayer.FadeOut(num);
            if (waitForFade)
            {
                GameSystem.Instance.AddWait(new Wait(num, WaitTypes.WaitForAudio, audioLayer.StopAudio));
            }
            if (currentAudio[AudioType.BGM].ContainsKey(channel))
            {
                currentAudio[AudioType.BGM].Remove(channel);
            }
        }
        public void ChangeVolumeOfBGM(int channel, float volume, float time)
        {
            int        channelByTypeChannel = GetChannelByTypeChannel(AudioType.BGM, channel);
            float      time2      = time / 1000f;
            AudioLayer audioLayer = channelDictionary[channelByTypeChannel];

            if (currentAudio[AudioType.BGM].ContainsKey(channel))
            {
                currentAudio[AudioType.BGM][channel].Volume = volume;
            }
            else
            {
                Debug.LogWarning("ChangeVolumeOfBGM could not find existing currentAudio for channel!");
            }
            audioLayer.StartVolumeFade(volume, time2);
        }
 public void RefreshLayerVolumes()
 {
     for (int i = 0; i < 6; i++)
     {
         AudioLayer audioLayer = channelDictionary[GetChannelByTypeChannel(AudioType.BGM, i)];
         audioLayer.SetBaseVolume(BGMVolume * GlobalVolume);
     }
     for (int j = 0; j < 8; j++)
     {
         AudioLayer audioLayer2 = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, j)];
         audioLayer2.SetBaseVolume(VoiceVolume * GlobalVolume);
     }
     for (int k = 0; k < 8; k++)
     {
         AudioLayer audioLayer3 = channelDictionary[GetChannelByTypeChannel(AudioType.SE, k)];
         audioLayer3.SetBaseVolume(SoundVolume * GlobalVolume);
     }
     for (int l = 0; l < 2; l++)
     {
         AudioLayer audioLayer4 = channelDictionary[GetChannelByTypeChannel(AudioType.System, l)];
         audioLayer4.SetBaseVolume(SystemVolume * GlobalVolume);
     }
 }
        public void PlayVoice(string filename, int channel, float volume)
        {
            MODTextController.MODCurrentVoiceLayerDetect = channel;
            AudioLayer audio = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            if (currentAudio[AudioType.Voice].ContainsKey(channel))
            {
                currentAudio[AudioType.Voice].Remove(channel);
            }
            currentAudio[AudioType.Voice].Add(channel, new AudioInfo(volume, filename));
            if (audio.IsPlaying())
            {
                audio.StopAudio();
            }
            audio.PlayAudio(filename, AudioType.Voice, volume);
            if (GameSystem.Instance.IsAuto)
            {
                audio.OnLoadCallback(delegate
                {
                    GameSystem.Instance.AddWait(new Wait(audio.GetRemainingPlayTime(), WaitTypes.WaitForVoice, null));
                });
            }
        }
        public void PlayVoice(string filename, int channel, float volume)
        {
            string text = filename.Substring(0, 4);
            bool   flag = false;

            switch (text)
            {
            case "chie":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVChie").BoolValue();
                break;

            case "eiji":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVEiji").BoolValue();
                break;

            case "kana":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVKana").BoolValue();
                break;

            case "kira":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVKira").BoolValue();
                break;

            case "mast":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVMast").BoolValue();
                break;

            case "mura":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVMura").BoolValue();
                break;

            case "riho":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVRiho").BoolValue();
                break;

            case "rmn_":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVRmn_").BoolValue();
                break;

            case "sari":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVSari").BoolValue();
                break;

            case "tika":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVTika").BoolValue();
                break;

            case "yayo":
                flag = BurikoMemory.Instance.GetGlobalFlag("GVYayo").BoolValue();
                break;

            default:
                flag = BurikoMemory.Instance.GetGlobalFlag("GVOther").BoolValue();
                break;
            }
            if (!flag)
            {
                AudioLayer audio = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];
                if (currentAudio[AudioType.Voice].ContainsKey(channel))
                {
                    currentAudio[AudioType.Voice].Remove(channel);
                }
                currentAudio[AudioType.Voice].Add(channel, new AudioInfo(volume, filename));
                if (audio.IsPlaying())
                {
                    audio.StopAudio();
                }
                audio.PlayAudio(filename, AudioType.Voice, volume);
                if (GameSystem.Instance.IsAuto)
                {
                    audio.OnLoadCallback(delegate
                    {
                        GameSystem.Instance.AddWait(new Wait(audio.GetRemainingPlayTime(), WaitTypes.WaitForVoice, null));
                    });
                }
            }
        }
        public void StopSE(int channel)
        {
            AudioLayer audioLayer = channelDictionary[GetChannelByTypeChannel(AudioType.SE, channel)];

            audioLayer.StopAudio();
        }
        public float GetRemainingVoicePlayTime(int channel)
        {
            AudioLayer audioLayer = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            return(audioLayer.GetRemainingPlayTime());
        }
        public void AddVoiceFinishCallback(int channel, AudioFinishCallback callback)
        {
            AudioLayer audioLayer = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            audioLayer.RegisterCallback(callback);
        }
        public bool IsVoicePlaying(int channel)
        {
            AudioLayer audioLayer = channelDictionary[GetChannelByTypeChannel(AudioType.Voice, channel)];

            return(audioLayer.IsPlaying());
        }