Esempio n. 1
0
        public static bool EachFrame()         // ret: ? 処理した。
        {
            if (1 <= PlayInfos.Count)
            {
                PlayInfo info = PlayInfos.Dequeue();

                if (info != null)
                {
                    switch (info.AlterCommand)
                    {
                    case PlayInfo.AlterCommand_e.NORMAL:
                        info.SE.HandleIndex %= DDSE.HANDLE_COUNT;
                        DDSoundUtils.Play(info.SE.Sound.GetHandle(info.SE.HandleIndex++));
                        break;

                    case PlayInfo.AlterCommand_e.STOP:
                        for (int index = 0; index < DDSE.HANDLE_COUNT; index++)
                        {
                            DDSoundUtils.Stop(info.SE.Sound.GetHandle(index));
                        }
                        break;

                    case PlayInfo.AlterCommand_e.LOOP:
                        DDSoundUtils.Play(info.SE.Sound.GetHandle(0), false);
                        break;

                    default:
                        throw new DDError();
                    }
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public DDMusic(DDSound sound_binding)
        {
            this.Sound = sound_binding;
            this.Sound.PostLoadeds.Add(handle => DDSoundUtils.SetVolume(handle, 0.0));             // ロードしたらミュートしておく。

            DDMusicUtils.Add(this);
        }
Esempio n. 3
0
        public DDSound(Func <byte[]> getFileData, int handleCount)
        {
            this.Func_GetFileData = getFileData;
            this.HandleCount      = handleCount;

            DDSoundUtils.Add(this);
        }
Esempio n. 4
0
        public static void EachFrame()
        {
            if (1 <= PlayInfos.Count)
            {
                PlayInfo info = PlayInfos.Dequeue();

                if (info != null)
                {
                    switch (info.Command)
                    {
                    case PlayInfo.Command_e.PLAY:
                        DDSoundUtils.Play(info.Music.Sound.GetHandle(0), info.Once, info.Resume);
                        break;

                    case PlayInfo.Command_e.VOLUME_RATE:
                        DDSoundUtils.SetVolume(info.Music.Sound.GetHandle(0), DDSoundUtils.MixVolume(DDGround.MusicVolume, info.Music.Volume) * info.VolumeRate);
                        break;

                    case PlayInfo.Command_e.STOP:
                        DDSoundUtils.Stop(info.Music.Sound.GetHandle(0));
                        break;

                    default:
                        throw new DDError();
                    }
                }
            }
        }
Esempio n. 5
0
        public DDMusic(DDSound sound_binding)
        {
            this.Sound            = sound_binding;
            this.Sound.PostLoaded = () => DDSoundUtils.SetVolume(this.Sound.GetHandle(0), 0.0);             // ロードしたらミュートしておく。

            DDMusicUtils.Add(this);
        }
Esempio n. 6
0
        public void UpdateVolume_Handles(int[] handles)
        {
            double mixedVolume = DDSoundUtils.MixVolume(DDGround.SEVolume, this.Volume);

            foreach (int handle in handles)
            {
                DDSoundUtils.SetVolume(handle, mixedVolume);
            }
        }
Esempio n. 7
0
        public void UpdateVolume_NoCheck()
        {
            double mixedVolume = DDSoundUtils.MixVolume(DDGround.SEVolume, this.Volume);

            for (int index = 0; index < HANDLE_COUNT; index++)
            {
                DDSoundUtils.SetVolume(this.Sound.GetHandle(index), mixedVolume);
            }
        }
Esempio n. 8
0
        public static bool EachFrame()         // ret: ? 処理した。
        {
            if (1 <= PlayInfos.Count)
            {
                PlayInfo info = PlayInfos.Dequeue();

                if (info != null)
                {
                    switch (info.AlterCommand)
                    {
                    case PlayInfo.AlterCommand_e.NORMAL:
                        info.SE.HandleIndex++;
                        info.SE.HandleIndex %= info.SE.Sound.HandleCount;

                        if (DDSoundUtils.IsPlaying(info.SE.Sound.GetHandle(info.SE.HandleIndex)))
                        {
                            for (info.SE.HandleIndex = 0; info.SE.HandleIndex < info.SE.Sound.HandleCount; info.SE.HandleIndex++)
                            {
                                if (!DDSoundUtils.IsPlaying(info.SE.Sound.GetHandle(info.SE.HandleIndex)))
                                {
                                    goto foundNotPlaying;
                                }
                            }

                            //info.SE.HandleIndex = info.SE.Sound.HandleCount;
                            info.SE.Sound.Extend();

                            //ProcMain.WriteLog("音を拡張しました。" + info.SE.Sound.HandleCount);
                        }
foundNotPlaying:
                        DDSoundUtils.Play(info.SE.Sound.GetHandle(info.SE.HandleIndex));
                        break;

                    case PlayInfo.AlterCommand_e.STOP:
                        for (int index = 0; index < info.SE.Sound.HandleCount; index++)
                        {
                            DDSoundUtils.Stop(info.SE.Sound.GetHandle(index));
                        }
                        break;

                    case PlayInfo.AlterCommand_e.LOOP:
                        DDSoundUtils.Play(info.SE.Sound.GetHandle(0), false);
                        break;

                    default:
                        throw new DDError();
                    }
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 9
0
        public bool IsPlaying()
        {
            if (this.Handles != null)
            {
                for (int index = 0; index < this.HandleCount; index++)
                {
                    if (DDSoundUtils.IsPlaying(this.Handles[index]))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 10
0
        public static void EachFrame()
        {
            if (1 <= PlayInfos.Count)
            {
                PlayInfo info = PlayInfos.Dequeue();

                if (info != null)
                {
                    switch (info.Command)
                    {
                    case PlayInfo.Command_e.PLAY:
                        DDSoundUtils.Play(info.Music.Sound.GetHandle(0), info.Once, info.Resume);
                        break;

                    case PlayInfo.Command_e.VOLUME_RATE:
                        DDSoundUtils.SetVolume(info.Music.Sound.GetHandle(0), DDSoundUtils.MixVolume(DDGround.MusicVolume, info.Music.Volume) * info.VolumeRate);
                        break;

                    case PlayInfo.Command_e.STOP:
                        DDSoundUtils.Stop(info.Music.Sound.GetHandle(0));

#if true // 再生していたローカルBGMのみ解放する。
                        if (info.Music.Locally)
                        {
                            info.Music.Sound.Unload();
                        }
#else // 全てのローカルBGMを解放する。
                        DDMusicUtils.UnloadLocally();
#endif
                        break;

                    default:
                        throw new DDError();
                    }
                }
            }
        }
Esempio n. 11
0
        public DDSound(Func <byte[]> getFileData)
        {
            this.Func_GetFileData = getFileData;

            DDSoundUtils.Add(this);
        }