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

public class Menu : MonoBehaviour {

	public GameObject toHide;
	public LineRenderer lr;

	void Start() {
		toHide.SetActive (true);
	}

	void Update () {
		if(Input.anyKeyDown) {
			toHide.SetActive (false);
		}
		float[] spectrum = new float[1024];

		GetComponent<AudioSource> ().GetSpectrumData (spectrum, 0, FFTWindow.Rectangular);

		lr.numPositions = 1024;
		for (int i = 1; i < spectrum.Length - 1; i++) {
			lr.SetPosition(i, new Vector2 (i - 1, spectrum [i] * 1000));
		}
		for (int i = spectrum.Length - 1; i > 1; i--) {
			lr.SetPosition(i, new Vector2 (i, spectrum [i] * 1000));
		}
	}
	public void Play() {
		Application.LoadLevel (1);
	}
	public void Mute() {
		if (AudioListener.volume != 1) {
			AudioListener.volume = 1;
		} else {
			AudioListener.volume = 0;
		}
	}
	public void Quit() {
		Application.Quit();
	}
}
