12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using UnityEngine;
- [RequireComponent(typeof(AudioSource))]
- public class OVRLipSyncContext : OVRLipSyncContextBase
- {
- public override void Init()
- {
- base.Init();
- }
- private void Update()
- {
- this.micSensitivity = GameMain.Instance.LipSyncMgr.Variable.MicSensitivity;
- this.audioMute = GameMain.Instance.LipSyncMgr.Variable.Mute;
- this.micVolume = GameMain.Instance.LipSyncMgr.Variable.MicVolume;
- }
- private void OnAudioFilterRead(float[] data, int channels)
- {
- if (OVRLipSync.IsInitialized() != OVRLipSync.Result.Success || this.audioSource == null)
- {
- return;
- }
- for (int i = 0; i < data.Length; i++)
- {
- data[i] *= this.micSensitivity;
- }
- lock (this)
- {
- if (base.Context != 0U)
- {
- OVRLipSync.Flags flags = OVRLipSync.Flags.None;
- if (this.delayCompensate)
- {
- flags |= OVRLipSync.Flags.DelayCompensateAudio;
- }
- OVRLipSync.Frame frame = base.Frame;
- OVRLipSync.ProcessFrameInterleaved(base.Context, data, flags, frame);
- }
- }
- if (this.audioMute)
- {
- for (int j = 0; j < data.Length; j++)
- {
- data[j] *= 0f;
- }
- }
- else
- {
- for (int k = 0; k < data.Length; k++)
- {
- data[k] *= this.micVolume;
- }
- }
- }
- [SerializeField]
- private float micSensitivity = 10f;
- [SerializeField]
- private bool audioMute;
- [SerializeField]
- private float micVolume;
- [SerializeField]
- [Header("遅延対応")]
- private bool delayCompensate = true;
- }
|