// Script:         jamTemplate.ltgs 
// Description:    Create a song template for jamming. A jam marker will be created 
//                 Number of bars and tracks can be specified by the userArgs
//                 Inputs, Outputs can be specified by args
// User Arguments: 
//		1: nbBars (optional, default is 4)
//		2: nbNewTracks (optional, default is 3)
// Arguments: 
//		1: input (optional)
//		2: outputs (optional)
//	
// Author : LoopToGo 

if $nbTracks
	printInMessageBox "This script must be used with an empty song only!"
	endScriptDynamic	// We must not mess with an existing song
endIf
 
// Setting default values         
variable nbBars 4
variable nbNewTracks 3      

// Getting user arguments    
if $userArg1    
   variable nbBars $userArg1 
endIf   

if $userArg2    
   variable nbNewTracks $userArg2
endIf   

// We must clear the user args for next user
setUserArgs

// Getting arguments    
if $arg1
	variable input $arg1
endIf

if $arg2
	variable output1 $arg2
endIf

if $arg3
	variable output2 $arg3
endIf

for track 1 $nbNewTracks

	variable trackName Track & $track

	addChain $trackName
	
	if $input
		setAudioInputs	$trackName $input
	endIf
	
	if $output1 
		if $output2
			setAudioOutputs	$trackName $output1 $output2
		endIf
	endIf
	
	addRecordLoop $trackName JamLoop & $track 2 2 + $nbBars
	
	// We alternate the color
	
	variable oddCheck $track/2 1
	if 2*$oddCheck = $track
		setChainColor $trackName 120 0 0	// Dark red
	else
		setChainColor $trackName green
	endIf
	
endFor	
 
addJamMarker 2 "First empty loop" 1 1 
 
