print $arg1 $arg2 $arg3

getLoopType loopType $selectedLoopID

print $loopType $selectedLoopType

//ifNot $selectedLoopType = Automation

//	printInMessageBox "You must select an automation curve!"

//	endScriptDynamic
//endIf

ifNot $editingCurveID

	printInMessageBox "Right-click a curve a select Edit Automation Directly!"

	endScriptDynamic
endIf

if $arg1 = RampUp
	
	clearAutomationCurve $editingCurveID
	
	addPointToAutomationCurve $editingCurveID  0 $arg2 
	addPointToAutomationCurve $editingCurveID  1.0 $arg3
		
endIf

if $arg1 = RampDown

	clearAutomationCurve $editingCurveID
	
	addPointToAutomationCurve $editingCurveID  0 $arg3 
	addPointToAutomationCurve $editingCurveID  1.0 $arg2
		
endIf

if $arg1 = Triangle
	
	clearAutomationCurve $editingCurveID

	addPointToAutomationCurve $editingCurveID  0 $arg2
	addPointToAutomationCurve $editingCurveID  .5 $arg3 
	addPointToAutomationCurve $editingCurveID  1.0 $arg2
		
endIf

if $arg1 = Square

	clearAutomationCurve $editingCurveID
	
	addPointToAutomationCurve $editingCurveID  0 $arg3
	addPointToAutomationCurve $editingCurveID  .499 $arg3
	addPointToAutomationCurve $editingCurveID  .501 $arg2 
	addPointToAutomationCurve $editingCurveID  1.0 $arg2
		
endIf

if $arg1 = Sin
    clearAutomationCurve $editingCurveID

    variable range $arg3 - $arg2
    
    // 17 points to create 16 segments (Full Sine Cycle)
    // Formula: Value = Min + (Range * Multiplier)
    addPointToAutomationCurve $editingCurveID  0.0000  $arg2 + $range * 0.500
    addPointToAutomationCurve $editingCurveID  0.0625  $arg2 + $range * 0.691
    addPointToAutomationCurve $editingCurveID  0.1250  $arg2 + $range * 0.853
    addPointToAutomationCurve $editingCurveID  0.1875  $arg2 + $range * 0.961
    addPointToAutomationCurve $editingCurveID  0.2500  $arg3                  // Peak (1.0)
    addPointToAutomationCurve $editingCurveID  0.3125  $arg2 + $range * 0.961
    addPointToAutomationCurve $editingCurveID  0.3750  $arg2 + $range * 0.853
    addPointToAutomationCurve $editingCurveID  0.4375  $arg2 + $range * 0.691
    addPointToAutomationCurve $editingCurveID  0.5000  $arg2 + $range * 0.500 // Midpoint
    addPointToAutomationCurve $editingCurveID  0.5625  $arg2 + $range * 0.309
    addPointToAutomationCurve $editingCurveID  0.6250  $arg2 + $range * 0.147
    addPointToAutomationCurve $editingCurveID  0.6875  $arg2 + $range * 0.039
    addPointToAutomationCurve $editingCurveID  0.7500  $arg2                  // Trough (0.0)
    addPointToAutomationCurve $editingCurveID  0.8125  $arg2 + $range * 0.039
    addPointToAutomationCurve $editingCurveID  0.8750  $arg2 + $range * 0.147
    addPointToAutomationCurve $editingCurveID  0.9375  $arg2 + $range * 0.309
    addPointToAutomationCurve $editingCurveID  1.0000  $arg2 + $range * 0.500
endIf

if $arg1 = SampleAndHold
    clearAutomationCurve $editingCurveID
	
	variable range $arg3 - $arg2


    // Sample and Hold creates "steps". We use 4 distinct levels.
    // Step 1
    addPointToAutomationCurve $editingCurveID  0.000  $arg2 + $range * 0.8
    addPointToAutomationCurve $editingCurveID  0.249  $arg2 + $range * 0.8
    // Step 2
    addPointToAutomationCurve $editingCurveID  0.250  $arg2 + $range * 0.2
    addPointToAutomationCurve $editingCurveID  0.495  $arg2 + $range * 0.2
    // Step 3
    addPointToAutomationCurve $editingCurveID  0.505  $arg3
    addPointToAutomationCurve $editingCurveID  0.745  $arg3
    // Step 4
    addPointToAutomationCurve $editingCurveID  0.755  $arg2 + $range * 0.5
    addPointToAutomationCurve $editingCurveID  1.000  $arg2 + $range * 0.5
endIf