// Script:         armRecord.ltgs 
// Description:    Script to arm for Recording
//				   Must be used with another script that will start the recording (Example: recordAfterArm.ltgs)
//				   Useful to start recording by playing keyboard. recordAfterArm.ltgs is an example of a recording
//				   if armRecord has been called and the user play a C3 (midi note = 48)
//				   This script will clear the loops starting at $songBar
//				   
// Arguments: 
//	
// Author : LoopToGo 

loadScript aliases.txt
 
armRecord	 // Will set the $isArmedForRecording system variable to 1 and will make sure to record midi event occuring before the preRecord Time 

// Make sure the record loop at songBar are empty

// 1 - First, we select it

unselectAllLoops

for loopNum 1 $nbLoops

	variable loopID loopID & $loopNum 
	variable ID $$loopID
	
	//print loopID : $loopID
	//print ID : $$loopID

	//getLoopName lName $ID 
	getLoopType lType $ID 
	//getLoopTrack lTrack $ID 
	getLoopStart lStart $ID 
	//getLoopEnd lEnd $ID 
	
	if $lStart = $songBar
		if $lType = Record
			selectLoop $ID
		endIf
	endIf
	
	//print $lTrack : $lName [ & $lType & ] $lStart $lEnd
	
endFor

// 2 - Then we force to clear all data without asking for permission
clearSelectedLoops 1 // 1 : Don't ask for permission


//print isArmedForRecording : $isArmedForRecording