This commit is contained in:
Chikashi Miyama 2019-12-07 19:20:44 +01:00
parent 3695f9d175
commit 0eec0a6e2f
8 changed files with 83 additions and 31 deletions

View file

@ -136,6 +136,7 @@
<e p="Threshold.cs" t="Include" />
</e>
<e p="PdConnection" t="Include">
<e p="Boundary.cs" t="Include" />
<e p="CylMidiTransitionController.cs" t="Include" />
<e p="DspController.cs" t="Include" />
<e p="ISpectrumGenerator.cs" t="Include" />

View file

@ -2,13 +2,12 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6a8ca49-0b91-43c0-a787-44b1fda29c5f" name="Default Changelist" comment="implement FFT waterfall">
<change afterPath="$PROJECT_DIR$/Assets/Scripts/PdConnection/Boundary.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Assets/Scripts/PdConnection/Boundary.cs.meta" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.UnityProject/.idea/contentModel.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.UnityProject/.idea/contentModel.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.UnityProject/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.UnityProject/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assembly-CSharp-Editor.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/Assembly-CSharp-Editor.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assembly-CSharp.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/Assembly-CSharp.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UnitTest.meta" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/ThridParty/Assets/Construction_Site_Column/Materials.meta" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/UnityProject.sln" beforeDir="false" afterPath="$PROJECT_DIR$/UnityProject.sln" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -36,9 +35,11 @@
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/Assets/Prefabs/Specttrum.prefab" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Editor/SequencerEditor.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Scripts/PdConnection/Boundary.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/4CD14385-55E6-4C0E-AEDA-2393D3C9CF4A/dc/2b798580/Texture2D.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Scenes/Examples/MIDI/script/PositionBind.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://C:/Program Files/Unity_2019.2.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.timeline/Runtime/Events/Marker.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Scenes/Examples/Texture/TextureMapper.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/ThridParty/KinectScript/EventPump.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Scripts/PdConnection/PdTimbreIdBind.cs" root0="FORCE_HIGHLIGHTING" />
@ -67,6 +68,7 @@
<setting file="file://$PROJECT_DIR$/Assets/Scripts/Visualizer/WaveformVisualizerBehaviour.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Scripts/PdConnection/MidiSyncedLoop.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/4CD14385-55E6-4C0E-AEDA-2393D3C9CF4A/b7/90060354/PlayableGraph.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Scripts/Visualizer/WaterfallVisualizer.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Assets/Scripts/PdConnection/PdArraySelector.cs" root0="FORCE_HIGHLIGHTING" />
@ -120,8 +122,6 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/Assets/Editor/UnitTest/UnitTest_SpectrumGeneratpr.cs" />
<option value="$PROJECT_DIR$/Assets/Scenes/Examples/PdBackendDemo/script/BoomBall.cs" />
<option value="$PROJECT_DIR$/Assets/Editor/UnitTest/UnitTest_SpectrumGenerator.cs" />
<option value="$PROJECT_DIR$/Assets/Scripts/PdConnection/SpectrumGenerator.cs" />
<option value="$PROJECT_DIR$/Assets/Editor/SpectrumGenerator.cs" />
@ -167,10 +167,12 @@
<option value="$PROJECT_DIR$/Assets/Scenes/Examples/Qlist/scripts/BallColorChanger.cs" />
<option value="$PROJECT_DIR$/Assets/Scenes/Examples/Qlist/scripts/QlistMarker.cs" />
<option value="$PROJECT_DIR$/Assets/Scenes/Examples/Qlist/scripts/SceneManager.cs" />
<option value="$PROJECT_DIR$/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs" />
<option value="$PROJECT_DIR$/Assets/Scripts/PdConnection/ReservedAction.cs" />
<option value="$PROJECT_DIR$/Assets/Scripts/PdConnection/ScheduledAction.cs" />
<option value="$PROJECT_DIR$/Assets/Scripts/PdConnection/CylMidiTransitionController.cs" />
<option value="$PROJECT_DIR$/Assets/Scripts/PdConnection/PauseBoundary.cs" />
<option value="$PROJECT_DIR$/Assets/Scripts/PdConnection/Boundary.cs" />
<option value="$PROJECT_DIR$/Assets/Scenes/Examples/Qlist/scripts/TimelineController.cs" />
</list>
</option>
</component>
@ -255,6 +257,7 @@
<workItem from="1575064364367" duration="3340000" />
<workItem from="1575100878147" duration="6707000" />
<workItem from="1575663620399" duration="4809000" />
<workItem from="1575732887966" duration="8480000" />
</task>
<task id="LOCAL-00001" summary="add Kinect Manager">
<created>1562485186899</created>

View file

@ -99,6 +99,7 @@
<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\Boundary.cs" />
<Compile Include="Assets\Scripts\PdConnection\CylMidiTransitionController.cs" />
<Compile Include="Assets\Scripts\PdConnection\DspController.cs" />
<Compile Include="Assets\Scripts\PdConnection\ISpectrumGenerator.cs" />

View file

@ -433,6 +433,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
playableDirector: {fileID: 1549059515}
stateManager: {fileID: 1788337936}
initTransitionFactor: 10
--- !u!320 &1549059515
PlayableDirector:
m_ObjectHideFlags: 0
@ -445,7 +446,7 @@ PlayableDirector:
m_PlayableAsset: {fileID: 11400000, guid: dd88d8a2bd5beda41a4bc9a6e2f2d080, type: 2}
m_InitialState: 0
m_WrapMode: 0
m_DirectorUpdateMode: 1
m_DirectorUpdateMode: 3
m_InitialTime: 0
m_SceneBindings:
- key: {fileID: -2136880647211988772, guid: dd88d8a2bd5beda41a4bc9a6e2f2d080, type: 2}

View file

@ -124,7 +124,7 @@ MonoBehaviour:
m_PostExtrapolationMode: 0
m_PreExtrapolationMode: 1
m_PostExtrapolationTime: Infinity
m_PreExtrapolationTime: 1
m_PreExtrapolationTime: 0
m_DisplayName: BlueToRed
- m_Version: 1
m_Start: 2
@ -154,7 +154,7 @@ MonoBehaviour:
m_ExposedParameterNames: []
m_AnimationCurves: {fileID: 0}
m_Recordable: 0
m_PostExtrapolationMode: 0
m_PostExtrapolationMode: 1
m_PreExtrapolationMode: 1
m_PostExtrapolationTime: 1
m_PreExtrapolationTime: 2

View file

@ -5,7 +5,7 @@ using UnityEngine.Playables;
namespace cylvester
{
public class TimelineController : MonoBehaviour, INotificationReceiver
public class TimelineController : MonoBehaviour
{
[SerializeField] private PlayableDirector playableDirector;
[SerializeField] private StateManager stateManager;
@ -13,51 +13,64 @@ namespace cylvester
[SerializeField] private float initTransitionFactor = 1f;
private IList<QlistMarker> qlistMarkers_;
private Boundary boundary_;
private float speed_;
public void Start()
{
var timeline = (TimelineAsset)playableDirector.playableAsset;
var markerTrack = timeline.markerTrack;
var markers = markerTrack.GetMarkers();
var markers = timeline.markerTrack.GetMarkers();
qlistMarkers_ = new List<QlistMarker>();
foreach (var marker in markers)
qlistMarkers_.Add((QlistMarker)marker);
playableDirector.Stop();
playableDirector.time = 0;
playableDirector.Play();
boundary_ = new Boundary(null, null);
UpdateSpeed();
}
public void OnStateChanged(IStateReader stateManager)
{
var stateName = stateManager.CurrentState.Title;
foreach (var qlistMarker in qlistMarkers_)
var numMarkers = qlistMarkers_.Count;
for (var i = 0; i < numMarkers; ++i)
{
if (qlistMarker.id != stateName) continue;
if (qlistMarkers_[i].id != stateName)
continue;
//playableDirector.Stop(); //This resets speed to 1, so I had to cut it.
playableDirector.time = qlistMarker.time;
playableDirector.time = qlistMarkers_[i].time;
var previousMarkerTime = i > 0 ? (double?) qlistMarkers_[i - 1].time : null;
var nextMarkerTime = i < numMarkers - 1 ? (double?) qlistMarkers_[i + 1].time : null;
boundary_ = new Boundary(previousMarkerTime, nextMarkerTime);
playableDirector.Play();
break;
}
}
public void OnNotify(Playable origin, INotification notification, object context)
private void Update()
{
if (!stateManager.NextState.HasValue)
if (playableDirector.state == PlayState.Paused)
return;
var nextState = stateManager.NextState.Value;
var prevState = stateManager.PreviousState.Value; //ToDO this is the same as nextState???
var deltaTime = Time.deltaTime;
var expectedTimeIncrement = speed_ * deltaTime;
var expectedTimeInTimeline = playableDirector.time + expectedTimeIncrement;
Debug.Log("next State " + prevState.Title);
Debug.Log("prev State " + prevState.Title);
if (notification.id == nextState.Title)
if (boundary_.IsInside(expectedTimeInTimeline))
{
playableDirector.Pause(); // reaches the next state (marker) in timeline
playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(initTransitionFactor); // Max added this instead of .Stop
playableDirector.time = expectedTimeInTimeline;
playableDirector.Evaluate();
}
else
{
playableDirector.Pause();
UpdateSpeed();
}
}
private void UpdateSpeed()
{
speed_ = initTransitionFactor;
}
}
}

View file

@ -0,0 +1,30 @@
namespace cylvester
{
public class Boundary
{
private readonly double? min_;
private readonly double? max_;
public Boundary(double? min, double? max)
{
min_ = min;
max_ = max;
}
public bool IsInside(double value)
{
if (min_.HasValue)
{
if (value < min_.Value)
return false;
}
if (max_.HasValue)
{
if (value > max_.Value)
return false;
}
return true;
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e2af2d984d364c6f87b65a1293490a58
timeCreated: 1575735381