Icon representing a recipe

Recipe: Slider Defaults 1.0

created by brow42

Profile


Name
Slider Defaults 1.0
ID
38552
Shared with
Public
Parent
None
Children
None
Created on
February 12, 2012 at 05:13 AM UTC
Updated on
February 12, 2012 at 05:13 AM UTC
Description

Saves the slider defaults into a segment note, and then sets the sliders on subsequent runs. Clear the note to set new defaults. Props to ST for the idea to use note spaces!

Best for


Code


--[[ * Slider Defaults * * Original Author: Brow42 2/11/2012 * * Saves defaults for the behavior slidres into a segment note (default 2) * Automatically sets the sliders to the defaults on subsequent executions. * To set new defaults, delete the note. * * Props to ST for using the note spaces! --]] title = 'Slider Defaults' seg = 2 -- where to store the defaults print(title) stored = structure.GetNote(seg) function dialog.MessageBox(text,title,button1,button2) local d = dialog.CreateDialog(title) d.text = dialog.AddLabel(text) d.b1 = dialog.AddButton(button1,1) if button2 then d.b2 = dialog.AddButton(button2,2) end return dialog.Show(d) end function Set() local d = dialog.CreateDialog(title) d.l1 = dialog.AddLabel('Set your default values (stored in notes mode):') d.l2 = dialog.AddLabel('(To set new defaults, clear note on segment '..tostring(seg)) d.bs = dialog.AddSlider('Band Str. Factor:', behavior.GetBandStrengthFactor(), 0.5, 1.5, 1) d.ci = dialog.AddSlider('Cl. Import.:', behavior.GetClashImportance(), 0.0, 1.0, 2) d.wa = dialog.AddSlider('Wiggle Acc.:', behavior.GetWiggleAccuracy(), 0, 7, 2) d.sa = dialog.AddSlider('Shake Acc.:', behavior.GetShakeAccuracy(), 0, 4, 0) d.bssa = dialog.AddSlider('Buried Acc. Factor:', behavior.GetBuriedSidechainShakeAccuracy(), 0.0, 1.0, 3) d.essa = dialog.AddSlider('Exposed Acc. Factor:', behavior.GetExposedSidechainShakeAccuracy(), 0.0, 1.0, 3) d.okay = dialog.AddButton('Set',1) d.cancel = dialog.AddButton('Cancel',0) local rc = dialog.Show(d) if rc == 0 then print('Canceled') return false end local note = string.format('Slider Defaults: %f %f %f %f %f %f', d.bs.value, d.ci.value, d.wa.value, d.sa.value, d.bssa.value, d.essa.value) structure.SetNote(seg,note) local msg = 'Defaults have been store in Note mode seg. #'..tostring(seg) print(msg) dialog.MessageBox(msg,'','Okay') return true end function Get() local rc, _, v1, v2, v3, v4, v5 , v6 = string.find( structure.GetNote(seg), '^Slider Defaults: (.*) (.*) (.*) (.*) (.*) (.*)') if rc == nil then return false end rc = pcall ( function() v1,v2,v3,v4,v5, v6 = tonumber(v1), tonumber(v2), tonumber(v3), tonumber(v4), tonumber(v5), tonumber(v6) end ) if rc == false or v1 == nil or v2 == nil or v3 == nil or v4 == nil or v5 == nil or v6 == nil then print('Unable to parse note') return false end print('Setting defaults from seg #'..tostring(seg)) print('Band Strength:',v1) print('Clash Importance:',v2) print('Wiggle Accuracy:',v3) print('Shake Accuracy:',v4) print('Buried Sidechain Accuracy:',v5) print('Exposed Sidechain Accuracy:',v6) behavior.SetBandStrengthFactor(v1) behavior.SetClashImportance(v2) behavior.SetWiggleAccuracy(v3) behavior.SetShakeAccuracy(v4) behavior.SetBuriedSidechainShakeAccuracy(v5) behavior.SetExposedSidechainShakeAccuracy(v6) return true end if (stored ~= '' ) then if (Get() == true) then return end local rc = dialog.MessageBox('Note #'..tonumber(seg)..' is not empty, overwrite?','','Yes','No') if rc == 1 then Set() else print('Not overwritten') end else Set() end

Comments