Skip to content

Commit

Permalink
Improve feedback interpolator logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-f-cruz committed Aug 14, 2024
1 parent bf54b18 commit bce0027
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 63 deletions.
108 changes: 68 additions & 40 deletions src/Extensions/InterpolateContinuousFeedback.bonsai
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,16 @@
<WorkflowBuilder Version="2.8.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp"
xmlns:p1="clr-namespace:Bonsai.Numerics.Interpolation;assembly=Bonsai.Numerics"
xmlns:dsp="clr-namespace:Bonsai.Dsp;assembly=Bonsai.Dsp"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
<Expression xsi:type="WorkflowInput">
<Name>Source1</Name>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Merge" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="dsp:Rescale">
<dsp:Min>0</dsp:Min>
<dsp:Max>1</dsp:Max>
<dsp:RangeMin>0</dsp:RangeMin>
<dsp:RangeMax>1</dsp:RangeMax>
<dsp:RescaleType>Clamp</dsp:RescaleType>
</Combinator>
</Expression>
<Expression xsi:type="WorkflowInput">
<Name>Source2</Name>
</Expression>
<Expression xsi:type="WorkflowInput">
<Name>Source3</Name>
</Expression>
<Expression xsi:type="GroupWorkflow">
<Name>CreateInterpolator</Name>
<Expression xsi:type="rx:Defer">
<Name>InterpolateContinuousFeedback</Name>
<Workflow>
<Nodes>
<Expression xsi:type="WorkflowInput">
Expand All @@ -40,11 +22,28 @@
<rx:Count>1</rx:Count>
</Combinator>
</Expression>
<Expression xsi:type="rx:AsyncSubject">
<Name>feedback</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>feedback</Name>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>Item1.ConverterLutInput</Selector>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Take">
<rx:Count>1</rx:Count>
</Combinator>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Merge" />
</Expression>
<Expression xsi:type="WorkflowInput">
<Name>Source2</Name>
<Expression xsi:type="SubscribeSubject">
<Name>feedback</Name>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>Item1.ConverterLutOutput</Selector>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Take">
Expand All @@ -63,40 +62,69 @@
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:CreateLinear" />
</Expression>
<Expression xsi:type="rx:AsyncSubject">
<Name>interpolator</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>feedback</Name>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>Item2</Selector>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="rx:Merge" />
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="dsp:Rescale">
<dsp:Min>0</dsp:Min>
<dsp:Max>1</dsp:Max>
<dsp:RangeMin>0</dsp:RangeMin>
<dsp:RangeMax>1</dsp:RangeMax>
<dsp:RescaleType>Clamp</dsp:RescaleType>
</Combinator>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>interpolator</Name>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="Interpolation" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:Interpolate" />
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="2" To="6" Label="Source1" />
<Edge From="3" To="4" Label="Source1" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="5" To="6" Label="Source2" />
<Edge From="6" To="7" Label="Source1" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="11" Label="Source1" />
<Edge From="7" To="8" Label="Source1" />
<Edge From="8" To="9" Label="Source1" />
<Edge From="9" To="10" Label="Source1" />
<Edge From="10" To="11" Label="Source2" />
<Edge From="11" To="12" Label="Source1" />
<Edge From="12" To="13" Label="Source1" />
<Edge From="13" To="14" Label="Source1" />
<Edge From="15" To="16" Label="Source1" />
<Edge From="16" To="17" Label="Source1" />
<Edge From="17" To="18" Label="Source1" />
<Edge From="18" To="21" Label="Source1" />
<Edge From="19" To="20" Label="Source1" />
<Edge From="20" To="21" Label="Source2" />
<Edge From="21" To="22" Label="Source1" />
</Edges>
</Workflow>
</Expression>
<Expression xsi:type="PropertyMapping">
<PropertyMappings>
<Property Name="Interpolation" />
</PropertyMappings>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:Interpolate" />
</Expression>
<Expression xsi:type="WorkflowOutput" />
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="2" To="7" Label="Source1" />
<Edge From="3" To="5" Label="Source1" />
<Edge From="4" To="5" Label="Source2" />
<Edge From="5" To="6" Label="Source1" />
<Edge From="6" To="7" Label="Source2" />
<Edge From="7" To="8" Label="Source1" />
</Edges>
</Workflow>
</WorkflowBuilder>
33 changes: 10 additions & 23 deletions src/main.bonsai
Original file line number Diff line number Diff line change
Expand Up @@ -3771,16 +3771,7 @@
<Name>feedbackSource</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>feedbackSource</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>deviceFeedback</Name>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>ConverterLutInput</Selector>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>ConverterLutOutput</Selector>
<Name>thisFeedback</Name>
</Expression>
<Expression xsi:type="IncludeWorkflow" Path="Extensions\InterpolateContinuousFeedback.bonsai" />
<Expression xsi:type="rx:PublishSubject">
Expand Down Expand Up @@ -3845,23 +3836,19 @@
<Edge From="4" To="5" Label="Source1" />
<Edge From="6" To="7" Label="Source1" />
<Edge From="7" To="8" Label="Source1" />
<Edge From="9" To="13" Label="Source1" />
<Edge From="9" To="10" Label="Source1" />
<Edge From="10" To="11" Label="Source1" />
<Edge From="10" To="12" Label="Source1" />
<Edge From="11" To="13" Label="Source2" />
<Edge From="12" To="13" Label="Source3" />
<Edge From="13" To="14" Label="Source1" />
<Edge From="12" To="13" Label="Source1" />
<Edge From="13" To="17" Label="Source1" />
<Edge From="14" To="15" Label="Source1" />
<Edge From="15" To="16" Label="Source1" />
<Edge From="16" To="20" Label="Source1" />
<Edge From="17" To="18" Label="Source1" />
<Edge From="18" To="19" Label="Source1" />
<Edge From="16" To="17" Label="Source2" />
<Edge From="18" To="20" Label="Source1" />
<Edge From="19" To="20" Label="Source2" />
<Edge From="21" To="23" Label="Source1" />
<Edge From="22" To="23" Label="Source2" />
<Edge From="20" To="21" Label="Source1" />
<Edge From="21" To="22" Label="Source1" />
<Edge From="22" To="23" Label="Source1" />
<Edge From="23" To="24" Label="Source1" />
<Edge From="24" To="25" Label="Source1" />
<Edge From="25" To="26" Label="Source1" />
<Edge From="26" To="27" Label="Source1" />
</Edges>
</Workflow>
</Expression>
Expand Down

0 comments on commit bce0027

Please sign in to comment.