Fixed #125
This commit is contained in:
parent
2955f202a7
commit
9d6e037de9
3 changed files with 50 additions and 48 deletions
|
@ -5,29 +5,34 @@ using UnityEngine.Playables;
|
|||
|
||||
namespace cylvester
|
||||
{
|
||||
|
||||
public enum CYL_Command
|
||||
{
|
||||
OneBarLoopButton = 86,
|
||||
FourBarLoopButton = 94,
|
||||
NextScelectedScene = 18,
|
||||
CurrentSelectedScene = 17,
|
||||
instaTrig = 2
|
||||
}
|
||||
|
||||
public class MidiTransitionController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int oneBarLoopButton = 86;
|
||||
[SerializeField] private int fourBarLoopButton = 94;
|
||||
[SerializeField] private PlayableDirector playableDirector;
|
||||
|
||||
private int oneBarLoop = 96;
|
||||
private int fourBarLoop = 384;
|
||||
private const int cmd_instaTrig = 2;
|
||||
private const int cmd_nextSelectedScene = 18;
|
||||
private const int cmd_currentSelectedScene = 17;
|
||||
[SerializeField] private PlayableDirector playableDirector;
|
||||
[SerializeField, Range(1, 16)] private int channel = 1;
|
||||
[SerializeField] StateManager stateManager;
|
||||
|
||||
private const int oneBarLoopLength = 96;
|
||||
private const int fourBarLoopLength = 384;
|
||||
|
||||
private bool instaChangeActive;
|
||||
|
||||
private int currentTick;
|
||||
private float transitionLength = 16; //sets the duration in Seconds, how long a transition has to be in "TimeLine" to be played back correctly when CYLVESTER is hooked up correctly
|
||||
private float restTimeS = 1f; //init transTime is 1 Second
|
||||
|
||||
[SerializeField] private int currentSelectedScene;
|
||||
[SerializeField] private int nextSelectedScene;
|
||||
|
||||
[SerializeField, Range(1, 16)] private int channel = 1;
|
||||
|
||||
[SerializeField] StateManager stateManager;
|
||||
int currentSelectedScene = 0;
|
||||
int nextSelectedScene = 0;
|
||||
|
||||
public void OnSyncReceived(MidiSync midiSync, int counter)
|
||||
{
|
||||
|
@ -37,47 +42,42 @@ namespace cylvester
|
|||
public void OnMidiMessageReceived(MidiMessage mes)
|
||||
{
|
||||
|
||||
if (mes.Status - 176 == channel - 1) //Which Channel
|
||||
if (mes.Status - 176 == channel - 1) //Choose Midi-Channel
|
||||
{
|
||||
|
||||
if (mes.Data1 == cmd_nextSelectedScene)
|
||||
switch (mes.Data1)
|
||||
{
|
||||
nextSelectedScene = mes.Data2; //Get next Schene Update
|
||||
}
|
||||
case (byte) CYL_Command.NextScelectedScene:
|
||||
nextSelectedScene = mes.Data2; //Get next selected Scene
|
||||
break;
|
||||
|
||||
if (mes.Data1 == cmd_instaTrig)
|
||||
{
|
||||
case (byte) CYL_Command.instaTrig:
|
||||
instaChangeActive = true;
|
||||
}
|
||||
break;
|
||||
|
||||
if (mes.Data1 == cmd_currentSelectedScene)
|
||||
{
|
||||
case (byte) CYL_Command.CurrentSelectedScene:
|
||||
currentSelectedScene = mes.Data2; //Get current selected Scene
|
||||
|
||||
if (instaChangeActive)
|
||||
{
|
||||
stateManager.SelectedState = currentSelectedScene;
|
||||
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(10);
|
||||
// Debug.Log("Instatrig " + currentSelectedScene);
|
||||
// Debug.Log("Last selected Scene new " + lastSelectedScene);
|
||||
instaChangeActive = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
if (mes.Data1 == oneBarLoopButton) //Button fourBarLoop
|
||||
{
|
||||
RestTime(fourBarLoop - currentTick % fourBarLoop);
|
||||
case (byte) CYL_Command.FourBarLoopButton:
|
||||
RestTime(fourBarLoopLength - currentTick % fourBarLoopLength);
|
||||
TimelinePlaybackSpeed();
|
||||
stateManager.SelectedState = nextSelectedScene;
|
||||
}
|
||||
break;
|
||||
|
||||
if (mes.Data1 == fourBarLoopButton) //Button oneBarLoop
|
||||
{
|
||||
RestTime(oneBarLoop - currentTick % oneBarLoop);
|
||||
case (byte) CYL_Command.OneBarLoopButton:
|
||||
RestTime(oneBarLoopLength - currentTick % oneBarLoopLength);
|
||||
TimelinePlaybackSpeed();
|
||||
stateManager.SelectedState = nextSelectedScene;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace cylvester
|
|||
{
|
||||
int SelectedState { set; }
|
||||
State[] States { get; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public struct State
|
||||
|
|
|
@ -420,7 +420,7 @@ samples/kick.wav kick \, read -resize samples/closed.wav closed;
|
|||
#X connect 5 0 4 0;
|
||||
#X connect 6 0 7 0;
|
||||
#X restore 405 71 pd shmem;
|
||||
#N canvas 700 143 1014 1074 CYLVESTERmidi 1;
|
||||
#N canvas 700 143 1014 1074 CYLVESTERmidi 0;
|
||||
#X obj 192 306 bng 15 250 50 0 4bar_trig_sim empty 4_Bar_trigger_Sim
|
||||
17 7 0 10 -203904 -1 -1;
|
||||
#X obj 192 287 bng 15 250 50 0 1bar_trig_sim empty 1_Bar_trigger_Sim
|
||||
|
|
Loading…
Reference in a new issue