Skip to content

Instantly share code, notes, and snippets.

@gmodeblog
Created March 30, 2015 01:41
Show Gist options
  • Save gmodeblog/487771aa6dd37d28df13 to your computer and use it in GitHub Desktop.
Save gmodeblog/487771aa6dd37d28df13 to your computer and use it in GitHub Desktop.
const int SAMPLE_NUM = 512;
LineRenderer line;
line = gameObject.AddComponent<LineRenderer>();
//好きな色を指定しています。
line.material.color = Color.cyan;
//ちょうどいい太さを指定しています。
line.SetWidth(0.065f, 0.065f);
line.SetVertexCount(SAMPLE_NUM);
float[] audioWaveFloat = new float[SAMPLE_NUM];
audioWaveFloat = extraAudioSource.audio.GetSpectrumData(SAMPLE_NUM, 0, FFTWindow.BlackmanHarris);
for (int i = 0; i < SAMPLE_NUM; i++)
{
line.SetPosition(i, new Vector3(Mathf.Log(i + 1), audioWaveFloat[i], 0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment