void Update() { synth.feedback = transform.position.x * 0.3f + 0.5f; synth.modfeedback = transform.position.z * 0.3f + 0.5f; synth.modulation = transform.position.y * 0.75f; if (!isPlaying) { if (transform.position.y > 0.4) { isPlaying = true; synth.KeyOn(note); } } else if (transform.position.y <= 0.4) { isPlaying = false; synth.KeyOff(); } }
// Update is called once per frame void Update() { if (Input.GetMouseButton(0)) { transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0f, 0f, 20f); float note_on = notes[(int)(Mathf.Floor(Mathf.Abs(transform.position.x + 1f) * 5f) % 8f)] + Mathf.Floor(transform.position.y + 1 * 2) * 12f + 20f; if (!selected) { synth.KeyOn(note_on); } selected = true; } else { if (selected) { selected = false; synth.KeyOff(); } } }