2019-10-30 15:02:20 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
|
|
|
|
|
namespace cylvester
|
|
|
|
|
{
|
|
|
|
|
public class MidiSyncedLoop : MonoBehaviour
|
|
|
|
|
{
|
2020-01-21 22:31:06 +00:00
|
|
|
|
[SerializeField, Range(1, 128)] private int loopLengthInBeat = 1;
|
2019-10-30 15:02:20 +00:00
|
|
|
|
[SerializeField] private UnityEvent loopStarted;
|
|
|
|
|
|
|
|
|
|
public void OnSyncReceived(MidiSync midiSync, int counter)
|
|
|
|
|
{
|
|
|
|
|
var loopLengthTicks = loopLengthInBeat * 24;
|
|
|
|
|
if(counter % loopLengthTicks == 0)
|
|
|
|
|
loopStarted.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|