1_创建一些方块

2_创建脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Auds1 : MonoBehaviour
{
    public GameObject[] obj;
    public AudioClip audionew;
    private string devices;
    float[] date=new float[1280];
    private void Start()
    {
        devices = Microphone.devices[0];
        audionew = Microphone.Start(devices, true, obj.Length, 44100);
    }

    private void Update()
    {
        int ofset = Microphone.GetPosition(devices)-obj.Length;
        audionew.GetData(date, ofset);
        for (int i = 0; i < obj.Length; i++)
        {
            obj[i].gameObject.transform.localScale = new Vector3(1, date[i] * 15, 1);
        }
    }
}

网址:Microphone-Start - Unity 脚本 API

           Microphone - Unity 脚本 API

     

XIAN - 读取外部音频 -

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐