set AppleScript's text item delimiters to space
tell application id "com.figure53.QLab.4" to tell front workspace
repeat while cue "PAN" is running
set x to translation x of cue "DUMVID"
set y to translation y of cue "DUMVID"
set {x, y} to {my constrainValue(x / 100, 0.01, 0.99), my constrainValue(y / 100, 0.01, 0.99)}
set batchText to (1 - x) * y & linefeed & (x * y) & linefeed & (1 - x) * (1 - y) & linefeed & x * (1 - y) as text
set {fader1, fader2, fader3, fader4} to my batchAwk(batchText)
cue "AUDIO" setLevel row 0 column 1 db fader1
cue "AUDIO" setLevel row 0 column 2 db fader2
cue "AUDIO" setLevel row 0 column 3 db fader3
cue "AUDIO" setLevel row 0 column 4 db fader4
end repeat
end tell
set AppleScript's text item delimiters to ""
on constrainValue(theNumber, minLimit, maxLimit)
if theNumber < minLimit then
return minLimit
else if theNumber > maxLimit then
return maxLimit
else
return theNumber
end if
end constrainValue
on batchAwk(theText)
return paragraphs of (do shell script "echo " & quoted form of theText & " | awk '{print 1+20*log($1)/(log(10))}'")
end batchAwk