Example #1
0
        //----- method -----

        public void Initialize(SoundParam defaultSoundParam)
        {
            if (initialized)
            {
                return;
            }

            this.defaultSoundParam = defaultSoundParam;

            player = new CriAtomExPlayer();

            soundParams        = new Dictionary <SoundType, SoundParam>();
            managedSoundSheets = new Dictionary <string, SoundSheet>();
            soundElements      = new List <SoundElement>();

            // デフォルトのサウンド設定を適用.
            SetSoundParam();

            // サウンドイベントを受信.
            CriAtomExSequencer.SetEventCallback(SoundEventCallback, SoundEventSeparator.ToString());

            // サウンドの状態更新.
            Observable.EveryEndOfFrame().Subscribe(_ => UpdateElement());

            // 一定周期で未使用状態になったAcbの解放を行う.
            Observable.Interval(TimeSpan.FromSeconds(5f)).Subscribe(_ => ReleaseSoundSheet());

            initialized = true;
        }
Example #2
0
        /// <summary>
        /// 再生設定を登録.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="param"></param>
        public void RegisterSoundType(SoundType type, SoundParam param)
        {
            soundParams[type] = param;

            // 再生中の音量に適用.
            foreach (var soundElement in soundElements)
            {
                if (soundElement.Type == type)
                {
                    SetVolume(soundElement, soundParams[type].volume);
                }
            }
        }
Example #3
0
        /// <summary>
        /// 再生設定を取得.
        /// </summary>
        /// <param name="type"></param>
        public SoundParam GetSoundParam(SoundType type)
        {
            var param = soundParams.GetValueOrDefault(type);

            if (param == null)
            {
                // エラーが大量に発生しないように空のパラメータを追加.
                soundParams[type] = new SoundParam();

                param = soundParams[type];

                Debug.LogErrorFormat("未登録の再生属性が指定されました. ({0})", type);
            }

            return(param);
        }
Example #4
0
        public void Initialize(SoundParam defaultSoundParam)
        {
            if (initialized)
            {
                return;
            }

            this.defaultSoundParam = defaultSoundParam;

            player = new CriAtomExPlayer();

            soundParams        = new Dictionary <SoundType, SoundParam>();
            managedSoundSheets = new Dictionary <string, SoundSheet>();
            soundElements      = new List <SoundElement>();

            // デフォルトのサウンド設定を適用.
            SetSoundParam();

            // サウンドイベントを受信.

            CriAtomExSequencer.EventCallback soundEventCallback = (ref CriAtomExSequencer.CriAtomExSequenceEventInfo info) =>
            {
                if (onSoundEvent != null)
                {
                    onSoundEvent.OnNext(info);
                }
            };

            CriAtomExSequencer.OnCallback += soundEventCallback;

            // サウンドの状態更新.
            Observable.EveryEndOfFrame()
            .Subscribe(_ => UpdateElement())
            .AddTo(Disposable);;

            // 一定周期で未使用状態になったAcbの解放を行う.
            Observable.Interval(TimeSpan.FromSeconds(5f))
            .Subscribe(_ => ReleaseSoundSheet())
            .AddTo(Disposable);

            initialized = true;
        }