2019-10-29 20:47:06 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
|
|
|
|
namespace cylvester
|
|
|
|
|
{
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class PitchEvent : UnityEvent<float>
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PdPitchBind : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private PdBackend pdbackend;
|
|
|
|
|
[SerializeField, Range(1, 16)] private int channel = 1;
|
|
|
|
|
[SerializeField] private LevelEvent pitchChanged;
|
2019-11-22 17:38:28 +00:00
|
|
|
|
[SerializeField] bool logPitch;
|
2019-10-29 20:47:06 +00:00
|
|
|
|
private float pitch_;
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
var pitch = pdbackend.PitchArray.Data[channel - 1];
|
|
|
|
|
|
|
|
|
|
if (pitch_ != pitch)
|
|
|
|
|
{
|
|
|
|
|
pitch_ = pitch;
|
|
|
|
|
pitchChanged.Invoke(pitch_);
|
2019-11-22 17:38:28 +00:00
|
|
|
|
if (logPitch)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("Pitch: " + pitch);
|
|
|
|
|
}
|
2019-10-29 20:47:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|