Implement CYLtransitions into MidiTransitionController

Closes #121
This commit is contained in:
max 2019-12-05 22:08:56 +01:00
parent 71f1403494
commit 324816de02
8 changed files with 92 additions and 36 deletions

View file

@ -10,7 +10,7 @@ namespace cylvester
[SerializeField] private PlayableDirector playableDirector; [SerializeField] private PlayableDirector playableDirector;
[SerializeField] private StateManager stateManager; [SerializeField] private StateManager stateManager;
[SerializeField] private float initTransitionTime = 16f; [SerializeField] private float initTransitionFactor = 8f;
private IList<QlistMarker> qlistMarkers_; private IList<QlistMarker> qlistMarkers_;
@ -51,7 +51,7 @@ namespace cylvester
if (notification.id == nextState.Title) if (notification.id == nextState.Title)
{ {
playableDirector.Pause(); // reaches the next state (marker) in timeline playableDirector.Pause(); // reaches the next state (marker) in timeline
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(1); playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(initTransitionFactor);
} }
} }
} }

View file

@ -1054,9 +1054,7 @@ MonoBehaviour:
m_Name: Qlist Marker m_Name: Qlist Marker
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Time: 80 m_Time: 80
stateName: 'ShowAll stateName: ShowAll
'
--- !u!114 &-2843494771311315102 --- !u!114 &-2843494771311315102
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

View file

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1 m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0} m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.0013421604, g: 0.0011744275, b: 0.0008066663, a: 1} m_IndirectSpecularColor: {r: 0.0013490503, g: 0.0011814049, b: 0.0008122615, a: 1}
m_UseRadianceAmbientProbe: 0 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
@ -195,6 +195,9 @@ MonoBehaviour:
oneBarLoopButton: 86 oneBarLoopButton: 86
fourBarLoopButton: 94 fourBarLoopButton: 94
playableDirector: {fileID: 65620552} playableDirector: {fileID: 65620552}
lastSelectedScene: 0
currentSelectedScene: 0
nextSelectedScene: 0
channel: 3 channel: 3
stateManager: {fileID: 850208555} stateManager: {fileID: 850208555}
--- !u!114 &65620555 --- !u!114 &65620555
@ -211,8 +214,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
playableDirector: {fileID: 65620552} playableDirector: {fileID: 65620552}
stateManager: {fileID: 850208555} stateManager: {fileID: 850208555}
transitionController: {fileID: 65620554} initTransitionFactor: 8
initTransitionTime: 16
--- !u!1 &155821760 --- !u!1 &155821760
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -809,7 +811,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
attackSmooth: 1 attackSmooth: 1
releaseSmooth: 1 releaseSmooth: 3.44
ignore0: 0 ignore0: 0
onSmoothProcessed: onSmoothProcessed:
m_PersistentCalls: m_PersistentCalls:
@ -880,7 +882,7 @@ MonoBehaviour:
m_StringArgument: m_StringArgument:
m_BoolArgument: 0 m_BoolArgument: 0
m_CallState: 2 m_CallState: 2
channel: 0 channel: 5
--- !u!1 &736002103 --- !u!1 &736002103
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1240,7 +1242,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 41f237c64f02a2241a30c5c0b5c087e6, type: 3} m_Script: {fileID: 11500000, guid: 41f237c64f02a2241a30c5c0b5c087e6, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
logAll: 0 logAll: 1
logFiltered: 0 logFiltered: 0
filterStatusByte: 128 filterStatusByte: 128
--- !u!1 &859452785 --- !u!1 &859452785
@ -1617,7 +1619,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
attackSmooth: 1 attackSmooth: 1
releaseSmooth: 1 releaseSmooth: 2
ignore0: 0 ignore0: 0
onSmoothProcessed: onSmoothProcessed:
m_PersistentCalls: m_PersistentCalls:
@ -1688,7 +1690,7 @@ MonoBehaviour:
m_StringArgument: m_StringArgument:
m_BoolArgument: 0 m_BoolArgument: 0
m_CallState: 2 m_CallState: 2
channel: 0 channel: 4
--- !u!1 &1471219110 --- !u!1 &1471219110
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -147,9 +147,9 @@ MonoBehaviour:
uiBounds: uiBounds:
serializedVersion: 2 serializedVersion: 2
x: -2339 x: -2339
y: -232 y: -231
width: 3713 width: 3713
height: 3104 height: 3101
--- !u!114 &114350483966674976 --- !u!114 &114350483966674976
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

View file

@ -13,15 +13,23 @@ namespace cylvester
private int oneBarLoop = 96; private int oneBarLoop = 96;
private int fourBarLoop = 384; private int fourBarLoop = 384;
private int instaTrig = 2;
private int nextSelectedSceneOutput = 18;
private int lastSelectedSceneOutput = 17;
private bool instaChangeActive;
private int currentTick; 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 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 private float restTimeS = 1f; //init transTime is 1 Second
[SerializeField] private int lastSelectedScene = 0;
[SerializeField] private int currentSelectedScene = 0;
[SerializeField] private int nextSelectedScene;
[SerializeField, Range(1, 16)] private int channel = 1; [SerializeField, Range(1, 16)] private int channel = 1;
[SerializeField] StateManager stateManager; [SerializeField] StateManager stateManager;
public void OnSyncReceived(MidiSync midiSync, int counter) public void OnSyncReceived(MidiSync midiSync, int counter)
{ {
currentTick = counter; currentTick = counter;
@ -29,18 +37,46 @@ namespace cylvester
public void OnMidiMessageReceived(MidiMessage mes) public void OnMidiMessageReceived(MidiMessage mes)
{ {
if (mes.Status - 176 == channel - 1) //Which Channel if (mes.Status - 176 == channel - 1) //Which Channel
{ {
if (mes.Data1 == nextSelectedSceneOutput)
{
nextSelectedScene = mes.Data2; //Get next Schene Update
}
if (mes.Data1 == lastSelectedSceneOutput)
lastSelectedScene = mes.Data2; //Get current selected Scene
if (mes.Data1 == oneBarLoopButton) //Button fourBarLoop if (mes.Data1 == oneBarLoopButton) //Button fourBarLoop
{ {
RestTime(fourBarLoop - currentTick % fourBarLoop); RestTime(fourBarLoop - currentTick % fourBarLoop);
TimelinePlaybackSpeed(); TimelinePlaybackSpeed();
stateManager.SelectedState = nextSelectedScene;
} }
if (mes.Data1 == fourBarLoopButton) //Button oneBarLoop if (mes.Data1 == fourBarLoopButton) //Button oneBarLoop
{ {
RestTime(oneBarLoop - currentTick % oneBarLoop); RestTime(oneBarLoop - currentTick % oneBarLoop);
TimelinePlaybackSpeed(); TimelinePlaybackSpeed();
stateManager.SelectedState = nextSelectedScene;
}
if (mes.Data1 == instaTrig)
{
instaChangeActive = true;
if (instaChangeActive && (currentSelectedScene != lastSelectedScene))
{
currentSelectedScene = lastSelectedScene;
stateManager.SelectedState = lastSelectedScene;
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(10);
Debug.Log("Instatrig " + currentSelectedScene);
Debug.Log("Last selected Scene new " + lastSelectedScene);
instaChangeActive = false;
}
} }
} }
} }
@ -52,8 +88,7 @@ namespace cylvester
public void TimelinePlaybackSpeed() public void TimelinePlaybackSpeed()
{ {
float timelinePlaybackSpeed; float timelinePlaybackSpeed = transitionLength / Mathf.Clamp(restTimeS, 0.001f, transitionLength);
timelinePlaybackSpeed = transitionLength / Mathf.Clamp(restTimeS, 0.001f, transitionLength);
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(timelinePlaybackSpeed); //set playbackspeed of Timeline playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(timelinePlaybackSpeed); //set playbackspeed of Timeline
} }
} }

View file

@ -33,7 +33,7 @@ namespace cylvester
public class StateManager : MonoBehaviour, IStateManager public class StateManager : MonoBehaviour, IStateManager
{ {
private enum Operation public enum Operation
{ {
Rewind = 0, Rewind = 0,
Previous = 1, Previous = 1,
@ -85,6 +85,8 @@ namespace cylvester
sceneSelection = value; sceneSelection = value;
onStateChanged.Invoke(this); onStateChanged.Invoke(this);
} }
get
{ return sceneSelection; }
} }
public void OnMidiReceived(MidiMessage message) public void OnMidiReceived(MidiMessage message)
@ -110,6 +112,29 @@ namespace cylvester
} }
onStateChanged.Invoke(this); onStateChanged.Invoke(this);
} }
public void OnStateChanged(Operation operation)
{
switch (operation)
{
case Operation.Rewind:
if (sceneSelection == 0) return;
sceneSelection = 0;
break;
case Operation.Previous:
if (sceneSelection == 0) return;
sceneSelection--;
break;
case Operation.Next:
if (sceneSelection >= States.Length - 1) return;
sceneSelection++;
break;
default:
return;
}
onStateChanged.Invoke(this);
}
} }
} }

View file

@ -290,8 +290,8 @@ Roses_Front.wav \; TimbreID_Test.wav \;;
#X text 416 223 176... control channel 1; #X text 416 223 176... control channel 1;
#X obj 6 194 midirealtimein; #X obj 6 194 midirealtimein;
#X obj 242 41 netreceive -u 54345; #X obj 242 41 netreceive -u 54345;
#X obj 598 90 cnv 15 500 60 empty current PositionCloud 20 12 0 45 #X obj 598 90 cnv 15 500 60 empty current PontCloud 20 12 0 45 -204786
-204786 -66577 0; -66577 0;
#X obj 786 234 bng 50 250 50 0 empty empty next 15 25 0 10 -204786 #X obj 786 234 bng 50 250 50 0 empty empty next 15 25 0 10 -204786
-1 -1; -1 -1;
#X obj 596 227 bng 50 250 50 0 empty empty rewind 7 25 0 10 -261234 #X obj 596 227 bng 50 250 50 0 empty empty rewind 7 25 0 10 -261234
@ -302,10 +302,10 @@ Roses_Front.wav \; TimbreID_Test.wav \;;
-1 -1; -1 -1;
#X msg 692 303 send 176 127 1; #X msg 692 303 send 176 127 1;
#X msg 786 304 send 176 127 2; #X msg 786 304 send 176 127 2;
#X obj 594 46 cnv 12 500 30 empty previous PontCloud 20 12 0 25 -262130 #X obj 594 46 cnv 12 500 30 empty previous needles 20 12 0 25 -262130
-66577 0;
#X obj 596 152 cnv 12 500 30 empty next PositionCloud 20 12 0 25 -262130
-66577 0; -66577 0;
#X obj 596 152 cnv 12 500 30 empty next Forces 20 12 0 25 -262130 -66577
0;
#X obj 879 467 declare -lib timbreID/timbreIDLib; #X obj 879 467 declare -lib timbreID/timbreIDLib;
#N canvas 28 541 1273 735 timbreID_example 0; #N canvas 28 541 1273 735 timbreID_example 0;
#X obj 77 657 nbx 3 28 -1e+037 1e+037 0 0 empty empty empty 0 -8 0 #X obj 77 657 nbx 3 28 -1e+037 1e+037 0 0 empty empty empty 0 -8 0
@ -420,7 +420,7 @@ samples/kick.wav kick \, read -resize samples/closed.wav closed;
#X connect 5 0 4 0; #X connect 5 0 4 0;
#X connect 6 0 7 0; #X connect 6 0 7 0;
#X restore 405 71 pd shmem; #X restore 405 71 pd shmem;
#N canvas -2849 181 1014 1074 CYLVESTERmidi 1; #N canvas 700 143 1014 1074 CYLVESTERmidi 1;
#X obj 192 306 bng 15 250 50 0 4bar_trig_sim empty 4_Bar_trigger_Sim #X obj 192 306 bng 15 250 50 0 4bar_trig_sim empty 4_Bar_trigger_Sim
17 7 0 10 -203904 -1 -1; 17 7 0 10 -203904 -1 -1;
#X obj 192 287 bng 15 250 50 0 1bar_trig_sim empty 1_Bar_trigger_Sim #X obj 192 287 bng 15 250 50 0 1bar_trig_sim empty 1_Bar_trigger_Sim
@ -803,8 +803,6 @@ samples/kick.wav kick \, read -resize samples/closed.wav closed;
#X connect 58 0 47 0; #X connect 58 0 47 0;
#X restore 598 377 pd CYLVESTERmidi; #X restore 598 377 pd CYLVESTERmidi;
#X text 701 378 <--- this is only for reference; #X text 701 378 <--- this is only for reference;
#X obj 758 193 ctlin 94 3;
#X obj 845 191 ctlin 86 3;
#X connect 0 0 2 0; #X connect 0 0 2 0;
#X connect 0 1 2 1; #X connect 0 1 2 1;
#X connect 0 2 2 2; #X connect 0 2 2 2;
@ -845,5 +843,3 @@ samples/kick.wav kick \, read -resize samples/closed.wav closed;
#X connect 30 0 11 0; #X connect 30 0 11 0;
#X connect 31 0 11 0; #X connect 31 0 11 0;
#X connect 36 0 11 0; #X connect 36 0 11 0;
#X connect 40 0 25 0;
#X connect 41 0 25 0;

View file

@ -1,7 +1,7 @@
Scene Title,BPM,Notes Scene Title,BPM,Notes
Intro,162,Show all Intro,120,Show all
needles,162,only needles needles,120,only needles
PontCloud,162,only points PontCloud,120,only points
PositionCloud,162,only points different view PositionCloud,120,only points different view
Forces,162,only forces Forces,120,only forces
ShowAll,162,all again different poisition ShowAll,120,all again different poisition
1 Scene Title BPM Notes
2 Intro 162 120 Show all
3 needles 162 120 only needles
4 PontCloud 162 120 only points
5 PositionCloud 162 120 only points different view
6 Forces 162 120 only forces
7 ShowAll 162 120 all again different poisition