LoginSignup
3
3

More than 3 years have passed since last update.

複数のマイクをつないでキャラごとにリップシンク

Last updated at Posted at 2019-05-16

概要

同じシーンに OVR Lipsync を適用したキャラが複数いる状態で、それぞれのキャラに別々のマイクの音声を割り当てる、を実現出来そうなヤツ。

※まだ試してない。 試した。

指定したのマイクの音声を拾う方法

以下より。

サンプルをちょっと編集。

[SerializeField] string deviceName = "マイクのデバイス名をここに";

void Start()
{
   var audio = GetComponent<AudioSource>();
   if(null == audio)
   {
      return;
   }
   audio.clip = Microphone.Start(deviceName, true, 10, 44100);
   audio.loop = true;

   /* https://support.unity3d.com/hc/en-us/articles/206485253-How-do-I-get-Unity-to-playback-a-Microphone-input-in-real-time-
    *
    * To control latency you will also need to call Microphone.GetPosition(); and choose your desired latency sample rate.
    * If you want no latency you can set this to “0” samples before the audio starts to play.
    */
   // 指定したサンプル数だけディレイさせる。0 なら即時。
   //while (!(0 < Microphone.GetPosition(deviceName))){ }

   //Debug.Log("start playing... position is " + Microphone.GetPosition(deviceName));
   audio.Play();
}

デバイス名一覧をインスペクターに表示する。
Inspector 用のエディター拡張を作るほどでも無いので、表示された一覧からコピペする。

#if UNITY_EDITOR
        public string[] microphoneDeviceNames;

        void Reset()
        {
            LoadMicrophoneDeviceNames();
        }

        void OnValidate()
        {
            LoadMicrophoneDeviceNames();
        }

        [ContextMenu("Load Microphone Device Names")]
        void LoadMicrophoneDeviceNames()
        {
            microphoneDeviceNames = Microphone.devices;
        }
#endif

UnityEngine.Microphone リファレンス

--

こちらもどうぞ

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3