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

public class MidiControlNumbers : MonoBehaviour {

	public int[] knobNumbers;
	private bool numbersSet = false;

	public bool setupDone;

	public Text controlsDisplay;


	Harmonizer[] harmonizers;

	// Use this for initialization
	void Start () {

		setupDone = false;
		harmonizers = FindObjectsOfType<Harmonizer> ();
	}
	
	// Update is called once per frame
	void Update ()
	{
		if(knobNumbers.Length < 10)
			controlsDisplay.text = "0" + knobNumbers.Length.ToString();
		else if(knobNumbers.Length >= 10)
			controlsDisplay.text = knobNumbers.Length.ToString();
		


		if (setupDone == false)
		{
			if (knobNumbers.Length < harmonizers.Length)
			{
				knobNumbers = MidiJack.MidiMaster.GetKnobNumbers ();
			}

			else
			{
				//knobNumbers = knobNumbers;
				setupDone = true;
			}
		}

		if (setupDone == true && numbersSet == false)
		{

			for (int i = 0; i < harmonizers.Length; i++)
			{
				harmonizers [i].knobNumber = knobNumbers [i];
			}

				//	item.knobNumber = knobNumbers [Random.Range (0, knobNumbers.Length)];
			

			numbersSet = true;
		}

	}
}
