2019-09-29 19:53:47 +00:00
|
|
|
|
using UnityEditor;
|
2019-09-29 16:04:26 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace cylvester
|
|
|
|
|
{
|
|
|
|
|
[CustomEditor(typeof(PdBackend))]
|
|
|
|
|
public class PdBackendEditor : Editor
|
|
|
|
|
{
|
2019-10-01 13:08:35 +00:00
|
|
|
|
private PdBackend pdBackend_;
|
2019-09-29 16:04:26 +00:00
|
|
|
|
private ILevelMeter[] levelMeters_;
|
2019-10-01 13:08:35 +00:00
|
|
|
|
private readonly string[] channels_ = {
|
2019-09-29 16:04:26 +00:00
|
|
|
|
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"
|
|
|
|
|
};
|
2019-10-01 13:08:35 +00:00
|
|
|
|
|
|
|
|
|
private readonly string[] samples_ =
|
|
|
|
|
{
|
|
|
|
|
"No Playback",
|
|
|
|
|
"Back_Back",
|
|
|
|
|
"Brutal_Synth",
|
|
|
|
|
"Dialog",
|
|
|
|
|
"Drums",
|
|
|
|
|
"Fox_Melo",
|
|
|
|
|
"Kick",
|
|
|
|
|
"Pads+Strings",
|
|
|
|
|
"Rose_Sax",
|
|
|
|
|
"Roses_Front"
|
|
|
|
|
};
|
2019-09-29 16:04:26 +00:00
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2019-10-01 13:08:35 +00:00
|
|
|
|
pdBackend_ = (PdBackend) target;
|
2019-09-29 16:04:26 +00:00
|
|
|
|
levelMeters_ = new ILevelMeter[16];
|
|
|
|
|
for (var i = 0; i < 16; ++i)
|
2019-09-29 19:53:47 +00:00
|
|
|
|
levelMeters_[i] = new LevelMeter(i);
|
2019-09-29 16:04:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnInspectorGUI ()
|
|
|
|
|
{
|
2019-10-01 13:08:35 +00:00
|
|
|
|
pdBackend_ = (PdBackend) target;
|
2019-09-29 16:04:26 +00:00
|
|
|
|
|
|
|
|
|
GUILayout.Space(5);
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
GUILayout.Label("Main Patch");
|
2019-10-01 13:08:35 +00:00
|
|
|
|
pdBackend_.mainPatch = GUILayout.TextField(pdBackend_.mainPatch, 30);
|
2019-09-29 16:04:26 +00:00
|
|
|
|
GUILayout.EndHorizontal();
|
2019-10-01 20:20:55 +00:00
|
|
|
|
|
2019-09-29 19:53:47 +00:00
|
|
|
|
if (Application.isPlaying)
|
|
|
|
|
{
|
2019-10-01 13:08:35 +00:00
|
|
|
|
RenderSamplePlayback();
|
|
|
|
|
RenderLevelMeters();
|
2019-09-29 19:53:47 +00:00
|
|
|
|
Repaint();
|
|
|
|
|
}
|
2019-09-29 16:04:26 +00:00
|
|
|
|
}
|
2019-10-01 13:08:35 +00:00
|
|
|
|
|
|
|
|
|
private void RenderSamplePlayback()
|
|
|
|
|
{
|
|
|
|
|
GUILayout.Space(5);
|
|
|
|
|
pdBackend_.samplePlayback = EditorGUILayout.Popup("Sample File to play", pdBackend_.samplePlayback, samples_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RenderLevelMeters()
|
|
|
|
|
{
|
|
|
|
|
GUILayout.Space(5);
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
foreach (var levelMeter in levelMeters_)
|
|
|
|
|
levelMeter.Render(pdBackend_.levelMeterArray);
|
|
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
}
|
2019-09-29 16:04:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|