12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- namespace RenderHeads.Media.AVProMovieCapture.Demos
- {
- public class AmbisonicAudioDemo : MonoBehaviour
- {
- [SerializeField] Transform[] _audioObjects = null;
- [SerializeField] AudioSource[] _audioSources = null;
- struct Instance
- {
- float x, y, z;
- float radius;
- }
- private int index;
-
-
- void Update()
- {
- float[] samples = new float[4];
- foreach (AudioSource audio in _audioSources)
- {
- audio.GetOutputData(samples, 0);
- float sample = Mathf.Abs(samples[2]);
- sample = Mathf.Sqrt(sample);
- float scale = audio.gameObject.transform.localScale.x;
-
- scale = 0.15f + Mathf.Lerp(scale, sample, Time.deltaTime * 20f) * 0.85f;
- audio.gameObject.transform.localScale = Vector3.one * scale;
- }
-
- int index = 0;
- foreach (Transform t in _audioObjects)
- {
-
-
-
-
- float time = Time.timeSinceLevelLoad + index * 1.321f;
- float tt = Mathf.PingPong(Mathf.Sin(time * 2.23f) + 1f, 2f) / 2f;
- float r = Mathf.Lerp(0.5f, 3f, tt);
- float x = Mathf.Sin(time * 1f) * r;
- float z = Mathf.Cos(time * 1.13f) * r;
- float y = Mathf.Sin(time * 1.23f) * 1f;
-
-
- t.position = new Vector3(x, y, z);
-
- index++;
- }
- }
- }
- }
|