soundvision/UnityProject/Assets/Scripts/PdConnection/MidiSyncedLoop.cs
2019-10-30 16:02:20 +01:00

21 lines
497 B
C#

using UnityEngine;
using UnityEngine.Events;
namespace cylvester
{
public class MidiSyncedLoop : MonoBehaviour
{
[SerializeField, Range(1, 100)] private int loopLengthInBeat = 1;
[SerializeField] private UnityEvent loopStarted;
public void OnSyncReceived(MidiSync midiSync, int counter)
{
var loopLengthTicks = loopLengthInBeat * 24;
if(counter % loopLengthTicks == 0)
loopStarted.Invoke();
}
}
}