Welcome to WSL!

## Expression for random value per given period of time.

Midgardsormr
Fusionator
Posts: 2169
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 40 times
Contact:

### Re: Expression for random value per given period of time.

I would set up the expression in a pair of new controls (Right-click the tool, choose Edit Controls...) or in a Custom Tool.
There is a special expression for a Point control:
Point ( [x expression], [y expression] )

If you've got the expression you quoted in the custom controls, it would look this: Point(XRandom,YRandom)

Here's a sample:

Code: Select all

``````{
Tools = ordered() {
CustomTool1 = Custom {
CtrlWZoom = false,
Inputs = {
PointIn1 = Input {
Value = { 0.59250657443369, 0.249633745393942 },
Expression = "Point(NumberIn1, NumberIn2)",
},
NumberIn1 = Input {
Value = 0.59250657443369,
Expression = ":randomseed(floor(time/6)); return random()",
},
NumberIn2 = Input {
Value = 0.249633745393942,
Expression = ":randomseed(floor(time/6)+1); return random()",
},
LUTIn1 = Input {
SourceOp = "CustomTool1LUTIn1",
Source = "Value",
},
LUTIn2 = Input {
SourceOp = "CustomTool1LUTIn2",
Source = "Value",
},
LUTIn3 = Input {
SourceOp = "CustomTool1LUTIn3",
Source = "Value",
},
LUTIn4 = Input {
SourceOp = "CustomTool1LUTIn4",
Source = "Value",
},
},
ViewInfo = OperatorInfo { Pos = { 635, 72 } },
},
CustomTool1LUTIn1 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 204, Green = 0, Blue = 0 },
NameSet = true,
},
CustomTool1LUTIn2 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 0, Green = 204, Blue = 0 },
NameSet = true,
},
CustomTool1LUTIn3 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 0, Green = 0, Blue = 204 },
NameSet = true,
},
CustomTool1LUTIn4 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 204, Green = 204, Blue = 204 },
NameSet = true,
}
}
}``````

Captain LeBuck
Fusioneer
Posts: 90
Joined: Tue Dec 02, 2014 6:34 pm

### Re: Expression for random value per given period of time.

Midgardsormr wrote:I would set up the expression in a pair of new controls (Right-click the tool, choose Edit Controls...) or in a Custom Tool.
There is a special expression for a Point control:
Point ( [x expression], [y expression] )

If you've got the expression you quoted in the custom controls, it would look this: Point(XRandom,YRandom)

Here's a sample:

Code: Select all

``````{
Tools = ordered() {
CustomTool1 = Custom {
CtrlWZoom = false,
Inputs = {
PointIn1 = Input {
Value = { 0.59250657443369, 0.249633745393942 },
Expression = "Point(NumberIn1, NumberIn2)",
},
NumberIn1 = Input {
Value = 0.59250657443369,
Expression = ":randomseed(floor(time/6)); return random()",
},
NumberIn2 = Input {
Value = 0.249633745393942,
Expression = ":randomseed(floor(time/6)+1); return random()",
},
LUTIn1 = Input {
SourceOp = "CustomTool1LUTIn1",
Source = "Value",
},
LUTIn2 = Input {
SourceOp = "CustomTool1LUTIn2",
Source = "Value",
},
LUTIn3 = Input {
SourceOp = "CustomTool1LUTIn3",
Source = "Value",
},
LUTIn4 = Input {
SourceOp = "CustomTool1LUTIn4",
Source = "Value",
},
},
ViewInfo = OperatorInfo { Pos = { 635, 72 } },
},
CustomTool1LUTIn1 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 204, Green = 0, Blue = 0 },
NameSet = true,
},
CustomTool1LUTIn2 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 0, Green = 204, Blue = 0 },
NameSet = true,
},
CustomTool1LUTIn3 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 0, Green = 0, Blue = 204 },
NameSet = true,
},
CustomTool1LUTIn4 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 204, Green = 204, Blue = 204 },
NameSet = true,
}
}
}``````

Thanks heaps!
Ok I am new to scripting so I am having difficulties getting this to work.
First, I tried Right-click on center of an ellipse mask > Modify with Expression. Then I typed the expression you provided. But the PointIn 1 values won't change ( See attachment).
Why is that?

The CustomTool you provided, how can I use it to transform the center of an ellipse mask?

Sorry for the stupid questions but I am totally new to this expression thingy.
So I really appreciate your help.
EDIT: I did Right-click Expression on Ellipse Center, and typed Point(CustomTool1.NumberIn1,CustomTool1.NumberIn1) instead. It works but is it technically correct?
ViTO
You do not have the required permissions to view the files attached to this post.

Midgardsormr
Fusionator
Posts: 2169
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 40 times
Contact:

### Re: Expression for random value per given period of time.

I almost never use the Expression modifier because it's cumbersome. In order for it to work the way you expected, you have to provide an output expression in the Point Out tab. Simply putting p1x in Point Expression X and p1y in Point Expression Y will do the trick.

The simple expression you wound up using is closer to how I would have done it. You can simply give the Center PointIn1 without using the Point() structure, though, because it's a two-dimensional control receiving a two-dimensional output.

Code: Select all

``````{
Tools = ordered() {
CtrlWZoom = false,
Inputs = {
MaskWidth = Input { Value = 1920, },
MaskHeight = Input { Value = 1080, },
PixelAspect = Input { Value = { 1, 1, }, },
ClippingMode = Input { Value = FuID { "None", }, },
Center = Input { Expression = "CustomTool1.PointIn1", },
},
ViewInfo = OperatorInfo { Pos = { 385, 181.5, }, },
},
},
ActiveTool = "Ellipse1",
}
``````
The most elegant method, in my opinion, is to do everything in the Ellipse itself by adding user controls to it to hold the random expressions:

Code: Select all

``````{
Tools = ordered() {
CtrlWZoom = false,
Inputs = {
MaskWidth = Input { Value = 1920, },
MaskHeight = Input { Value = 1080, },
PixelAspect = Input { Value = { 1, 1, }, },
ClippingMode = Input { Value = FuID { "None", }, },
Center = Input { Expression = "Point(Xrandom,Yrandom)", },
Xrandom = Input { Expression = ":randomseed(floor(time/6)); return random()", },
Yrandom = Input { Expression = ":randomseed(floor(time/6)+1); return random()", },
},
ViewInfo = OperatorInfo { Pos = { 385, 181.5, }, },
UserControls = ordered() {
Xrandom = {
INP_Default = 0,
INPID_InputControl = "SliderControl",
IC_ControlPage = 0,
},
Yrandom = {
IC_ControlPage = 0,
INPID_InputControl = "SliderControl",
},
},
},
},
ActiveTool = "Ellipse1",
}
``````
As I mentioned earlier, to add these user controls in Fusion 8, right-click the tool and choose "Edit Controls." If you're in Fu7, you need to run a tool script called "user controls" by right-clicking the tool, then choosing "Script > BMD > UserControls."

It takes a little bit of experimentation to figure out how the user controls dialogue works. Play with it for a while until you get the hang of its operation. I have been meaning write up a tutorial on it, but I don't have the time for that right now.

edit: typo

drwho79
Posts: 7
Joined: Fri Sep 08, 2017 5:13 am

### Re: Expression for random value per given period of time.

How would one go about randomizing a value at irregular intervals? One randomized value for the first 5 frames, then another for the next 2, then again 5, then 2...

Something along the lines of:
3-3-3-3-3-8-8-5-5-5-5-5-2-2-9-9-9-9-9-1-1-7-7-7-7-7... etc.

SecondMan
Posts: 4900
Joined: Thu Jul 31, 2014 5:31 pm
Been thanked: 52 times
Contact:

### Re: Expression for random value per given period of time.

drwho79 wrote: Tue May 22, 2018 1:40 pmHow would one go about randomizing a value at irregular intervals?

You don't have to use expressions for this. You can also use a couple of nested Random Modifiers. The below example outputs a number between 0 and 9 at irregular intervals in the Text+ node by nesting two Random Modifiers in the Blur node:

1. {
2.     Tools = ordered() {
3.         Text1 = TextPlus {
4.             Inputs = {
5.                 Width = Input { Value = 1920, },
6.                 Height = Input { Value = 1080, },
7.                 ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
8.                 Font = Input { Value = "Open Sans", },
9.                 StyledText = Input {
10.                     Value = "8",
11.                     Expression = "floor(Blur1.XBlurSize)",
12.                 },
13.                 Style = Input { Value = "Bold", },
14.                 ManualFontKerningPlacement = Input {
15.                     Value = StyledText {
16.                         Array = {
17.                         },
18.                         Value = ""
19.                     },
20.                 },
21.             },
22.             ViewInfo = OperatorInfo { Pos = { 550, 82.5 } },
23.         },
24.         Blur1 = Blur {
25.             Inputs = {
26.                 XBlurSize = Input {
27.                     SourceOp = "Random1",
28.                     Source = "Number",
29.                 },
30.             },
31.             ViewInfo = OperatorInfo { Pos = { 660, 82.5 } },
32.         },
33.         Random1 = KomkomDoorn.KD_NumberRandom {
34.             CtrlWZoom = false,
35.             Inputs = {
36.                 Maximumvalue = Input { Value = 10, },
37.                 Newvalueforeveryfieldframe = Input { Value = 0, },
38.                 Newvalueeveryframes = Input {
39.                     SourceOp = "Random2",
40.                     Source = "Number",
41.                 },
42.                 Interpolation = Input { Value = 0, },
43.             },
44.         },
45.         Random2 = KomkomDoorn.KD_NumberRandom {
46.             CtrlWZoom = false,
47.             Inputs = {
48.                 Minimumvalue = Input { Value = 5, },
49.                 Maximumvalue = Input { Value = 10, },
50.                 Newvalueforeveryfieldframe = Input { Value = 0, },
51.                 Newvalueeveryframes = Input { Value = 10, },
52.                 Interpolation = Input { Value = 0, },
53.             },
54.         }
55.     }
56. }

drwho79
Posts: 7
Joined: Fri Sep 08, 2017 5:13 am

### Re: Expression for random value per given period of time.

Thanks a bunch for your contribution! Unfortunately, I don't have the Studio version of Fusion so I can't access the Krokodove tools.

I was wondering if it could be done with nested while loops but as I'm still relatively new to this stuff, figuring it out is a bit of a struggle.

Code: Select all

``:this_num=1; total_num=4; hold_frames=6; t,n,v,prev=0,0,0,0; randomseed(1234); while t <= time do while v == prev do v = random(1,total_num); n=n+1; end; prev=v; t = t + hold_frames; end; return (v==this_num) and 1 or 0``

I'd really appreciate it if someone could take the time to explain in a bit more depth what is going on in the above snippet of code. It seems to be an infinite loop which is what I'm looking for. The t and n variables seem to operate as counters. V stands for value? And the t value has to remain equal to or lower than "time" in order to keep the loop going?

Midgardsormr
Fusionator
Posts: 2169
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 40 times
Contact:

### Re: Expression for random value per given period of time.

The solution depends on whether you need the number of frames to hold to also be random or if you want to animate that. Animating it is pretty easy. Going back up to the top and looking at this:

Code: Select all

``:randomseed(floor(time/6)) ; return random()``

You could replace floor(time/6) with a reference to an animated control:

Code: Select all

``:randomseed(tool.slider); return random()``

Animate the slider using stepped keyframes.

If you want the time period to also be random, you'll need something a bit longer. Here's the expression from the Glitch_TimeSegmenter (which I don't think I've published as a stand-alone tool yet, but it might be wrapped up in some of the GlitchTools macros available in Reactor):

Code: Select all

``````:i=0; seg=-1; randomseed(RandomSeed); while i<=time do seg=seg+1; i=i+random(MinimumSegmentLength,MaximumSegmentLength); end; return seg
``````

The variables RandomSeed, MinimumSegmentLength, and MaximumSegmentLength have their values provided by sliders on the tool. Here's an annotated look at it in an easier-to-read form:

1. i = 0                   -- A counter
2. seg = -1                -- The initial output value
3. randomseed(RandomSeed)  -- seeds the random number generator
4. while i <= time do      -- This loop executes when the frame number exceeds the counter value
5.     seg = seg + 1       -- Increments the output value
6.     i = i + random(MinimumSegmentLength, MaximumSegmentLength)  -- Chooses a random number between the min
7.                                                     -- and max slider values and adds it to the counter.
8.                                                     -- This always makes i greater than time, so the
9.                                                     -- loop won't execute for more than one frame at
10.                                                     -- a time.
11. end         -- end of while loop
12.
13. return seg       -- sends the result to the control

You can use this expression to set the random seed for your other control. The random number would change at random times, no more often than the MinimumSegmentLength and no less often than MaximumSegmentLength.

drwho79 wrote: Wed May 23, 2018 6:13 am Thanks a bunch for your contribution! Unfortunately, I don't have the Studio version of Fusion so I can't access the Krokodove tools.

I was wondering if it could be done with nested while loops but as I'm still relatively new to this stuff, figuring it out is a bit of a struggle.

Code: Select all

``:this_num=1; total_num=4; hold_frames=6; t,n,v,prev=0,0,0,0; randomseed(1234); while t <= time do while v == prev do v = random(1,total_num); n=n+1; end; prev=v; t = t + hold_frames; end; return (v==this_num) and 1 or 0``

I'd really appreciate it if someone could take the time to explain in a bit more depth what is going on in the above snippet of code. It seems to be an infinite loop which is what I'm looking for. The t and n variables seem to operate as counters. V stands for value? And the t value has to remain equal to or lower than "time" in order to keep the loop going?

I'll expand that expression just like I did my own:

1. this_num=1      -- A value to match
2. total_num=4     -- maximum output value
3. hold_frames=6       -- number of frames to wait before selecting a new value
4. t = 0               -- a counter to compare against the current time
5. n = 0               -- This appears to be doing nothing?
6. v = 0               -- The random generated value
7. prev = 0            -- The previously generated random value
8. randomseed(1234)    -- Seed is constant
9. while t <= time do  -- Loop executes only when it equals or exceeds the counter
10.
11.     while v == prev do          -- Loop executes only until v changes its value
12.                             -- (prevents it from sending the same
13.                             -- result twice in a row)
14.         v = random(1,total_num) -- Chooses a random integer between 1 and total_num
15.         n=n+1               -- Dead weight, maybe left over from the expression this
17.     end                     -- end of while loop
18.
19.     prev=v              -- Permits the inner while loop to execute next time around
20.     t = t + hold_frames     -- Increments the counter. It is now larger than time again,
21.                         -- which breaks the outer loop after it executes one time.
22. end                     -- end of while loop
23.
24. return (v==this_num) and 1 or 0 -- If v is equal to this_num, it is true. And returns its second
25.                         --  expression if the first is true. Otherwise it returns the first.
26.                         -- Or returns its first statement if it isn't false (which in Lua is
27.                         -- distinct from having the value "true"). Otherwise it returns its
28.                         -- second. See SecondMan's post above for an explanation of why
29.                         -- this is slightly more efficient than an if statement.

SecondMan
Posts: 4900
Joined: Thu Jul 31, 2014 5:31 pm
Been thanked: 52 times
Contact:

### Re: Expression for random value per given period of time.

drwho79 wrote: Wed May 23, 2018 6:13 amThanks a bunch for your contribution! Unfortunately, I don't have the Studio version of Fusion so I can't access the Krokodove tools.

Ah yes, I keep forgetting. Honestly, though, get Fusion Studio. Its cost is basically the same as a couple of good nights out and Krokodove alone is worth that.

drwho79
Posts: 7
Joined: Fri Sep 08, 2017 5:13 am

### Re: Expression for random value per given period of time.

Thanks so much for the very, very thorough explanation!

Here's a little comp demonstrating what I'm going for:

Code: Select all

``````{
Tools = ordered() {
Inputs = {
BorderWidth = Input { Value = 0.002, },
Solid = Input { Value = 0, },
MaskWidth = Input { Value = 1920, },
MaskHeight = Input { Value = 1080, },
PixelAspect = Input { Value = { 1, 1 }, },
ClippingMode = Input { Value = FuID { "None" }, },
Width = Input { Value = 0.2, },
Height = Input { Value = 0.2, },
},
ViewInfo = OperatorInfo { Pos = { 879, 154.5 } },
},
Background1 = Background {
Inputs = {
Width = Input { Value = 1920, },
Height = Input { Value = 1080, },
["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
TopLeftRed = Input { Value = 1, },
TopLeftGreen = Input { Value = 1, },
TopLeftBlue = Input { Value = 1, },
SourceOp = "Ellipse1",
}
},
ViewInfo = OperatorInfo { Pos = { 879, 194.5 } },
},
Text1 = TextPlus {
CtrlWZoom = false,
Inputs = {
Width = Input { Value = 1920, },
Height = Input { Value = 1080, },
["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
Font = Input { Value = "Open Sans", },
StyledText = Input { Value = "BLEEP", },
Style = Input { Value = "Light", },
ManualFontKerningPlacement = Input {
Value = StyledText {
Array = {
},
Value = ""
},
},
},
ViewInfo = OperatorInfo { Pos = { 1021, 153 } },
},
Merge1 = Merge {
Inputs = {
Blend = Input {
SourceOp = "Merge1Blend",
Source = "Value",
},
Background = Input {
SourceOp = "Background1",
Source = "Output",
},
Foreground = Input {
SourceOp = "Text1",
Source = "Output",
},
PerformDepthMerge = Input { Value = 0, },
},
ViewInfo = OperatorInfo { Pos = { 1021, 195 } },
},
Merge1Blend = BezierSpline {
SplineColor = { Red = 205, Green = 205, Blue = 205 },
NameSet = true,
KeyFrames = {
[0] = { 0, RH = { 5, 0 }, Flags = { Linear = true, Loop = true } },
[15] = { 0, LH = { 10, 0 }, RH = { 15.33, 0.33 }, Flags = { Linear = true } },
[16] = { 1, LH = { 15.67, 0.67 }, RH = { 17, 1 }, Flags = { Linear = true } },
[19] = { 1, LH = { 18, 1 }, RH = { 19.33, 0.67 }, Flags = { Linear = true } },
[20] = { 0, LH = { 19.67, 0.33 }, Flags = { Linear = true, Loop = true } }
}
},
Background2 = Background {
Inputs = {
Width = Input { Value = 1920, },
Height = Input { Value = 1080, },
["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
},
ViewInfo = OperatorInfo { Pos = { 1023, 266 } },
},
Merge3 = Merge {
Inputs = {
Background = Input {
SourceOp = "Background2",
Source = "Output",
},
Foreground = Input {
SourceOp = "Merge1",
Source = "Output",
},
PerformDepthMerge = Input { Value = 0, },
},
ViewInfo = OperatorInfo { Pos = { 1151, 221 } },
}
}
}``````

It's got a simple repeating pattern comprised of a longer segment (off time) and a shorter segment (on time). A bleep, if you will, going on and off so that the on-segment is always shorter. I'd like it to pick a random color each time it "bleeps". Furthermore, I'd like to have length sliders for the on and off segments that can be animated.

The on and off part is relatively easy but randomizing the color seems harder. (Should be a growing randomseed value that only grows when a bleep takes place.) I don't necessarily need to randomize the segment lengths. Are there any global variables available that could temporarily hold values?

SecondMan wrote: Wed May 23, 2018 11:18 am
Ah yes, I keep forgetting. Honestly, though, get Fusion Studio. Its cost is basically the same as a couple of good nights out and Krokodove alone is worth that.

I will, most likely. At its current price it does represent pretty insane value for money.

Stefan_R
Posts: 4
Joined: Fri Jun 11, 2021 6:12 am
Location: Berlin

### Re: Expression for random value per given period of time.

I try to achieve something similar. But also a bit different.

What I want is to create for "Alpha Gain Slider" in a "Merge" Node...
Where the "Alpha Gain" is always at 1. But after a random frame number the "Alpha Gain should" switch to "0".
For only 1 frame. And show whatever is in "MediaIn1". After that the "Alpha Gain" should switch to the valua 1 again,
and after another random number of frames it should again switch to "0". Again for only 1 frame.

Midgardsormr
Fusionator
Posts: 2169
Joined: Wed Nov 26, 2014 8:04 pm
Location: Los Angeles, CA, USA
Been thanked: 40 times
Contact:

### Re: Expression for random value per given period of time.

I have a little macro piece for that, too! Here's the FlickerSwitch from GlitchTools. Again, it's wrapped up in the macros and not visible on its own. I really ought to update the package at some point to pull these guys out where they can be used more easily.

Code: Select all

``````{
Tools = ordered() {
MT_Glitch_FlickerSwitch = Dissolve {
Transitions = {
[0] = "DFTDissolve"
},
CtrlWZoom = false,
NameSet = true,
Inputs = {
Mix = Input {
Value = 0,
Expression = ":t0=0; randomseed(RandomSeed); while t0<=time do off=random(MinimumOffTime,MaximumOffTime); on=random(MinimumOnTime,MaximumOnTime); t=time-t0; t0=t0+on+off; end; n=t0-on; if t>=off then return 1; else return 0; end",
},
Comments = Input { Value = "Randomly switches the Mix control between 0 and 1. Adjust the frequency of switching using the Max and Min sliders. \r\n\r\nMuse Effects Elements Library, Glitch Tools Collection\r\nby Bryan Ray.\r\nwww.musevfx.com", },
},
ViewInfo = OperatorInfo { Pos = { 370.667, 126.152 } },
Colors = {
TileColor = { R = 0.584313725490196, G = 0.294117647058824, B = 0.803921568627451 },
TextColor = { R = 0.725490196078431, G = 0.690196078431373, B = 0.592156862745098 },
},
UserControls = ordered() {
MinimumOffTime = {
INP_MaxAllowed = 10000,
INP_Integer = true,
INPID_InputControl = "SliderControl",
IC_ControlPage = 0,
INP_MaxScale = 30,
INP_Default = 3,
INP_MinAllowed = 0,
},
MaximumOffTime = {
INP_MaxAllowed = 10000,
INP_Integer = true,
INPID_InputControl = "SliderControl",
IC_ControlPage = 0,
INP_MaxScale = 60,
INP_Default = 10,
INP_MinScale = 1,
INP_MinAllowed = 0,
},
MinimumOnTime = {
INP_MaxAllowed = 10000,
INP_Integer = true,
INPID_InputControl = "SliderControl",
IC_ControlPage = 0,
INP_MaxScale = 30,
INP_Default = 3,
INP_MinAllowed = 0,
},
MaximumOnTime = {
INP_MaxAllowed = 10000,
INP_Integer = true,
INPID_InputControl = "SliderControl",
IC_ControlPage = 0,
INP_MaxScale = 60,
INP_Default = 10,
INP_MinScale = 1,
INP_MinAllowed = 0,
},
RandomSeed = {
INP_Default = 0,
IC_ControlPage = 0,
INPID_InputControl = "SliderControl",
},
}
}
},
ActiveTool = "MT_Glitch_FlickerSwitch"
}
``````
Expression link your AlphaGain control to the Mix control (the label is Background/Foreground, but the scripting name is Mix). For what you describe, Minimum and Maximum Off Time should both be 1, and the Min/Max On Time should be set such that you get the frequency of flicker you're after.

Stefan_R
Posts: 4
Joined: Fri Jun 11, 2021 6:12 am
Location: Berlin

### Re: Expression for random value per given period of time.

Thank you so much for the code.
Sadly I am a beginner. I did expressions in AE 10 years ago.
I also watched the training video bei Blackmagic and "fusion videos on youtube"
but it would be nice if you could go more into details.

EDIT:

I got it.
I insert the Code.

1. Expression link your AlphaGain control to the Mix control (The MIX Controll is the NEW NODE which appears
when you insert the code in Fusion. Just "paste it".
2. And in the "Mix Controll" there is a "Background/Foreground" slider. Just Link to that Slider. GOT IT!

THANK YOU AGAIN!