Script CHOP force cook

heyo!

so i have a script chop that doesnt have any inputs, but im utlziing Time to genrate a value, BUT it isnt cooking, becuase it doesnt have any input.

would be nice to have a force cook button on the Script CHOP!

i couldnt get the actual script to cook itself sof or now im just using a execte dat to force cook it…but imagine its not the best solution.

Hi @REM_Visuals,

you could add a custom parameter where you specify the time which will make it cook.

cheers
Markus

i had a parameter that was multiplying the time , but it still didnt force cook, from what i can tell it needs an input, but maybe i had the time set up wrong in the script.

i ended up just using a constant and speed input, so it cooks, works better and is seamingly cheaper

Hi @REM_Visuals

Would be interesting to see in what context the parameter doesn’t have the desired effect. But yes - an input that cooks is the safest path.

cheers
Markus

1 Like

this implementation wouldnt cook, the paramter code is wrong, chatgpt hasnt figured that part out fully, but i couldnt find the older version that i cleaned up…

def onSetupParameters(scriptOp):
    page = scriptOp.appendCustomPage('Custom')
    
    # Amplitude parameter
    p1 = page.appendFloat('Amplitude', label='Amplitude')
    p1.default = 1.0
    
    # StretchX parameter
    p2 = page.appendFloat('Stretchx', label='StretchX')
    p2.default = 1.0
    
    # Speed parameter
    p3 = page.appendFloat('Speed', label='Speed')
    p3.default = 1.0
    
    return

def onCook(scriptOp):
    import math
    import time
    
    # Get the custom parameters
    amplitude = scriptOp.par.Amplitude.eval()
    stretch_x = scriptOp.par.Stretchx.eval()
    speed = scriptOp.par.Speed.eval()
    
    # Get the internal time
    current_time = time.time() * speed
    
    # Calculate x and y based on the parametric equations for an infinity symbol
    x = amplitude * stretch_x * math.sin(current_time)
    y = amplitude * math.sin(2 * current_time)
    
    # Clear previous channels
    scriptOp.clear()
    
    # Append new channels
    scriptOp.appendChan("LfoX")
    scriptOp.appendChan("LfoY")
    
    # Set the channel values
    scriptOp['LfoX'][0] = x
    scriptOp['LfoY'][0] = y
    
    return

Hi @REM_Visuals

soon enough I’m sure :wink:
Yeah - a reference to the python module time will not cook, you would have to use an internal time like absTime.seconds which sets up a dependency and forces the cook.

def onSetupParameters(scriptOp):
    page = scriptOp.appendCustomPage('Custom')
    
    # Amplitude parameter
    p1 = page.appendFloat('Amplitude', label='Amplitude')
    p1.default = 1.0
    
    # StretchX parameter
    p2 = page.appendFloat('Stretchx', label='StretchX')
    p2.default = 1.0
    
    # Speed parameter
    p3 = page.appendFloat('Speed', label='Speed')
    p3.default = 1.0
    
    # Make it cook
    p4 = page.appendFloat('Time', label='Time')
    p4.default = 1.0
    p4.defaultExpr = "absTime.seconds"
    p4.defaultMode = ParMode.EXPRESSION    
    
    return

def onCook(scriptOp):
    
    # Get the custom parameters
    amplitude = scriptOp.par.Amplitude.eval()
    stretch_x = scriptOp.par.Stretchx.eval()
    speed = scriptOp.par.Speed.eval()
    
    # Get the internal time
    current_time = scriptOp.par.Time * speed
    
    # Calculate x and y based on the parametric equations for an infinity symbol
    x = amplitude * stretch_x * math.sin(current_time)
    y = amplitude * math.sin(2 * current_time)
    
    # Clear previous channels
    scriptOp.clear()
    
    # Append new channels
    scriptOp.appendChan("LfoX")
    scriptOp.appendChan("LfoY")
    
    # Set the channel values
    scriptOp['LfoX'][0] = x
    scriptOp['LfoY'][0] = y
    
    return

And just because I like CHOPs :slight_smile: :


base_infinity.tox (942 Bytes)

cheers
Markus

1 Like

of course… i didnt even think that using abstime would work. that makes a lot of sense.
anyway the speed chop makes more sense so casue when you multiplty the “time” it jumps and doesnt slow it down nicely…

and yeah!! love this chop version!!!
I tried figureding it out with two lfos, honestly i just couldnt get it to work, didnt think oif a pattern…so went the chat/script route,
but… :stuck_out_tongue: the script has Z and also the ability to strethc the X!!

and i shared the asset in a post, but here it is as well -

Hi @REM_Visuals,

ah nice. Just for completeness a version with all those as parameters of the component.

base_infinity.tox (950 Bytes)

cheers
Markus

omg, markus your such a G, this is awesome, makes my work useless hahaha…
thank you for this!!