Icon representing a recipe

Recipe: nicm25.htf.BandagesFreezer v1.00

created by Nicm25

Profile


Name
nicm25.htf.BandagesFreezer v1.00
ID
104858
Shared with
Public
Parent
None
Children
None
Created on
June 14, 2021 at 12:01 PM UTC
Updated on
June 14, 2021 at 12:01 PM UTC
Description

freeze as score threshold! (nullable segment select, number threshold, boolean boneonly, boolean resetfreezes)

Best for


Code


-- created by Nicm25; function pldc() local retd=dialog.CreateDialog("BandagesFreezer 1.00") retd.la=dialog.AddLabel(" nogood.. ..none.. ..good") retd.si=dialog.AddSlider("threshold",-0.25,-1.0,1.0,2) retd.ck=dialog.AddCheckbox("bone only",false) retd.cr=dialog.AddCheckbox("reset freezes",true) retd.bt=dialog.AddButton("OK",1) return retd end function plss() local lc=1 local retd={} for lc=1,structure.GetCount() do retd[lc]=selection.IsSelected(lc) and 1 or 0 end return retd end function run(avs,avx,avy,avz) local segs=0 local sege=0 local stct={} local lc=0 local setbb=false local setne=false local setth=0.0 if avx<-1.001 or avx>1.001 then return 1 end setbb=avy and true or false if avz then freeze.UnfreezeAll() end setth=avx if setth<0.0 then setne=true setth=1.0+setth end setth=(250.0-150.0/(1.1-setth))*(setne and -1.0 or 1.0) sege=#avs if selection.GetCount()>1.5 then for lc=1,sege do if selection.IsSelected(lc) then if segs<0.5 then segs=lc else sege=lc end end end else segs=1 for lc=1,sege do if structure.IsLocked(lc) then segs=lc+1 end end end selection.DeselectAll() for lc=segs,sege do if current.GetSegmentEnergyScore(lc)*(setne and -1.0 or 1.0)>setth then selection.Select(lc) end end freeze.FreezeSelected(true,not(setbb)) selection.DeselectAll() return 0 end local lfi=0 local tdr=pldc() lfi=dialog.Show(tdr) if lfi>0.5 then lfi=run(plss(),tdr.si.value,tdr.ck.value,tdr.cr.value) if lfi>0.5 then print("terminated by exception error") end end

Comments


Nicm25 Lv 1

thank you for your interest.
this is by product of bootstrap, where i prepare tools myself from beginning
and my personal 'Hand Tools, Freeze such package'(htf).

In this little script, freezing by energy score per segment,
do wiggling without affecting not good scores.
4 arguments
select: currently selected segment will be this argument(not in dialog), if none select is 'all apply'.
threshold: based on energy score, you can adjust to freezing range.
range: -1.0-1.0, default: -0.25, function: 1.0 is freeze to good side, -1.0 is freeze to not good side, 0.0 is almost none
boneonly: set whether to backbone only.
default: false, function: false is both freezes, true is backbone only
resetfreezes: set whether to running reset freezes.
default: true, function: false is none, true is run reset freezes
int return: whether it was successfully. function: 0 is okay, else is problem