Created
March 1, 2018 00:07
-
-
Save dilanshah/c6d9fa099ef13b0549484e45ffb2cf85 to your computer and use it in GitHub Desktop.
This script complements the audio visualizer script for initializing the parametric cubes,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[RequireComponent(typeof(AudioSource))] | |
public class AudioPeer : MonoBehaviour { | |
AudioSource _audioSource; | |
// from a sound theory spectrum standpoint all seven of those buckets are remapped to 512 values | |
public static float[] _samples = new float[512]; | |
// Use this for initialization | |
void Start () { | |
_audioSource = GetComponent<AudioSource> (); | |
} | |
// Update is called once per frame | |
void Update () { | |
GetSpectrumAudioSource (); | |
} | |
void GetSpectrumAudioSource() | |
{ | |
// get Spectrum Data takes samples, channel, and window data use Blackman to reduce data leakage | |
// get spectrum data and put it into _sampless | |
_audioSource.GetSpectrumData(_samples, 0, FFTWindow.Blackman); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment