soundvision/UnityProject/Assets/Scripts/PdConnection/MidiSyncedLoop.cs

22 lines
497 B
C#
Raw Normal View History

2019-10-30 15:02:20 +00:00
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();
}
}
}