CylMidiController can drive Timeline forwards and Backwards now
Bug: Playback deosnt stop for reverse.
This commit is contained in:
parent
9d6e037de9
commit
a757349071
4 changed files with 43 additions and 21 deletions
|
@ -105,13 +105,13 @@
|
|||
<Compile Include="Assets\Scripts\Math\BodyHolder.cs" />
|
||||
<Compile Include="Assets\Scripts\Math\Smoother.cs" />
|
||||
<Compile Include="Assets\Scripts\Math\Threshold.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\CylMidiTransitionController.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\DspController.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\ISpectrumGenerator.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\MidiLogger.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\MidiParser.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\MidiSequencer.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\MidiSyncedLoop.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\MidiTransitionController.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\PdArray.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\PdArrayContainer.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\PdArraySelector.cs" />
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace cylvester
|
|||
[SerializeField] private PlayableDirector playableDirector;
|
||||
[SerializeField] private StateManager stateManager;
|
||||
|
||||
[SerializeField] private float initTransitionFactor = 8f;
|
||||
[SerializeField] private float initTransitionFactor = 1f;
|
||||
|
||||
private IList<QlistMarker> qlistMarkers_;
|
||||
|
||||
|
@ -48,10 +48,15 @@ namespace cylvester
|
|||
return;
|
||||
|
||||
var nextState = stateManager.NextState.Value;
|
||||
if (notification.id == nextState.Title)
|
||||
var prevState = stateManager.PreviousState.Value; //ToDO this is the same as nextState???
|
||||
|
||||
Debug.Log("next State " + prevState.Title);
|
||||
Debug.Log("prev State " + prevState.Title);
|
||||
|
||||
if (notification.id == nextState.Title || notification.id == prevState.Title)
|
||||
{
|
||||
playableDirector.Pause(); // reaches the next state (marker) in timeline
|
||||
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(initTransitionFactor);
|
||||
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(initTransitionFactor); // Max added this instead of .Stop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,22 +8,30 @@ namespace cylvester
|
|||
|
||||
public enum CYL_Command
|
||||
{
|
||||
OneBarLoopButton = 86,
|
||||
FourBarLoopButton = 94,
|
||||
//these are the midi CCs coming from the CYL_Axoloti box
|
||||
OneBarLoopButton = 94,
|
||||
FourBarLoopButton = 86,
|
||||
NextScelectedScene = 18,
|
||||
CurrentSelectedScene = 17,
|
||||
instaTrig = 2
|
||||
instaTrig = 2,
|
||||
}
|
||||
|
||||
public class MidiTransitionController : MonoBehaviour
|
||||
public enum Timeline_Command
|
||||
{
|
||||
Forwards = 1,
|
||||
Backwards = -1
|
||||
}
|
||||
|
||||
public class CylMidiTransitionController : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private PlayableDirector playableDirector;
|
||||
[SerializeField, Range(1, 16)] private int channel = 1;
|
||||
[SerializeField] StateManager stateManager;
|
||||
[SerializeField] float instaTransitionSpeed = 10;
|
||||
|
||||
private const int oneBarLoopLength = 96;
|
||||
private const int fourBarLoopLength = 384;
|
||||
private const int oneBarTrigger = 96;
|
||||
private const int fourBarTrigger = 384;
|
||||
|
||||
private bool instaChangeActive;
|
||||
|
||||
|
@ -58,23 +66,32 @@ namespace cylvester
|
|||
case (byte) CYL_Command.CurrentSelectedScene:
|
||||
currentSelectedScene = mes.Data2; //Get current selected Scene
|
||||
|
||||
if (instaChangeActive)
|
||||
if (instaChangeActive) //This triggers instant Switch between states
|
||||
{
|
||||
stateManager.SelectedState = currentSelectedScene;
|
||||
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(10);
|
||||
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(instaTransitionSpeed);
|
||||
instaChangeActive = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case (byte) CYL_Command.FourBarLoopButton:
|
||||
RestTime(fourBarLoopLength - currentTick % fourBarLoopLength);
|
||||
TimelinePlaybackSpeed();
|
||||
if (nextSelectedScene > currentSelectedScene)
|
||||
{
|
||||
RestTime(fourBarTrigger - currentTick % fourBarTrigger);
|
||||
TimelinePlaybackSpeed((int) Timeline_Command.Forwards);
|
||||
stateManager.SelectedState = nextSelectedScene;
|
||||
}
|
||||
else
|
||||
{
|
||||
RestTime(fourBarTrigger - currentTick % fourBarTrigger);
|
||||
TimelinePlaybackSpeed((int)Timeline_Command.Backwards);
|
||||
stateManager.SelectedState = nextSelectedScene + 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case (byte) CYL_Command.OneBarLoopButton:
|
||||
RestTime(oneBarLoopLength - currentTick % oneBarLoopLength);
|
||||
TimelinePlaybackSpeed();
|
||||
RestTime(oneBarTrigger - currentTick % oneBarTrigger);
|
||||
TimelinePlaybackSpeed((int) Timeline_Command.Forwards);
|
||||
stateManager.SelectedState = nextSelectedScene;
|
||||
break;
|
||||
}
|
||||
|
@ -86,10 +103,10 @@ namespace cylvester
|
|||
restTimeS = restTick / 24.0f / stateManager.CurrentState.Bpm * 60;
|
||||
}
|
||||
|
||||
public void TimelinePlaybackSpeed()
|
||||
public void TimelinePlaybackSpeed(int direction)
|
||||
{
|
||||
float timelinePlaybackSpeed = transitionLength / Mathf.Clamp(restTimeS, 0.001f, transitionLength);
|
||||
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(timelinePlaybackSpeed); //set playbackspeed of Timeline
|
||||
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(timelinePlaybackSpeed * direction); //set playbackspeed of Timeline
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue