Hi All,
Longtime lurker, first time poster. I wrote a script that powers a Logic Pro articulation switcher called LAS. The following repeat loop takes ~3 seconds to parse the articulations in the .plist file and build lists which are sent via OSC messages to populate the articulation buttons (usually around 20 buttons).
Repeat loop code from the getArtList handler is below. Entire script here. Are there obvious optimizations I’m missing?
repeat with i from 1 to (number of items in p1)
set a to ""
set b to ""
set c to ""
try
set varArticulationsID to the value of property list item "ID" of property list item i of property list item "Articulations"
set varName to the value of property list item "Name" of property list item i of property list item "Articulations"
set varName to ("\"" & varName & "\"") #wrap in double quotes to escape string
set varSwitchesID to the value of property list item "ID" of property list item i of property list item "Switches"
if (varSwitchesID as text) contains "." then #Studio Horns/Strings create 100n.0 IDs
set t to (varSwitchesID as text)
set varSwitchesID to (text 1 thru -3 of t) as number
end if
set varSwitchesID to ("\"" & varSwitchesID & "\"")
set varType to the value of property list item "Status" of property list item i of property list item "Switches"
if varType = "NoteOn" then #some art sets have different names made with different versions of Logic
set varType to "Note On"
else if varType = "Poly Pressure" then
set varType to "Poly Aftertouch"
end if
set varType to ("\"" & varType & "\"")
(*if exists property list item "MidiChannel" of property list item i of property list item "Articulations" then
set varMidiChannel to the value of property list item "MidiChannel" of property list item i of property list item "Articulations"
else
set varMidiChannel to null
end if*)
(*if exists property list item "Symbol" of property list item i of property list item "Articulations" then
set varSymbol to the value of property list item "Symbol" of property list item i of property list item "Articulations"
set varSymbol to ("\"" & varType & "\"")
else
set varSymbol to ""
end if*)
if exists property list item "MB1" of property list item i of property list item "Switches" then
set varSelector to the value of property list item "MB1" of property list item i of property list item "Switches"
else
set varSelector to null
end if
#set varSelector to ("\"" & varSelector & "\"")
(*if exists property list item "Mode" of property list item i of property list item "Switches" then
set varMode to the value of property list item "Mode" of property list item i of property list item "Switches"
set varMode to ("\"" & varMode & "\"")
else
set varMode to ""
end if*)
if exists property list item "ValueLow" of property list item i of property list item "Switches" then
set varValueStart to the value of property list item "ValueLow" of property list item i of property list item "Switches"
else
set varValueStart to null
end if
#set varValueStart to ("\"" & varValueStart & "\"")
(*if exists property list item "ValueHigh" of property list item i of property list item "Switches" then
set varValueEnd to the value of property list item "ValueHigh" of property list item i of property list item "Switches"
else
set varValueEnd to null
end if*)
my clearMsg({9})
on error
if g_artSetByTrack = 0 then
my sendOSC("/message9 ", "s ", "Incompatible articulation set. ")
return 0
end if
end try
try
set varOutputType to the value of property list item "Status" of property list item "Output" of property list item i of property list item "Articulations"
if varOutputType = "NoteOn" then #some art sets have different names made with different versions of Logic
set varOutputType to "Note On"
else if varOutputType = "Poly Pressure" then
set varOutputType to "Poly Aftertouch"
end if
set varOutputType to ("\"" & varOutputType & "\"")
if exists property list item "MB1" of property list item "Output" of property list item i of property list item "Articulations" then
set varOutputSelector to the value of property list item "MB1" of property list item "Output" of property list item i of property list item "Articulations"
else
set varOutputSelector to null
end if
if exists property list item "ValueLow" of property list item "Output" of property list item i of property list item "Articulations" then
set varOutputValueStart to the value of property list item "ValueLow" of property list item "Output" of property list item i of property list item "Articulations"
else
set varOutputValueStart to null
end if
my clearMsg({9})
on error
if g_artSetByTrack = 0 then
my sendOSC("/message9 ", "s ", "Incompatible articulation set. ")
return 0
end if
end try
set a to varName & ":" & varArticulationsID
copy a to the end of myList
set b to varSwitchesID & ":[" & varType & ", " & varSelector & ", " & varValueStart & ", " & varOutputType & ", " & varOutputSelector & ", " & varOutputValueStart & "]" as text
copy b to the end of myList2
(*
set a to "varArticulationsID:" & varArticulationsID & ", " & ¬
"varName:" & varName & ", " & ¬
"varSwitchesID:" & varSwitchesID & ", " & ¬
"varType:" & varType & ", " & ¬
"varSelector:" & varSelector
if varMode ≠ "" then set a to a & ", " & "varMode:" & varMode
if varValueStart ≠ -1 then set a to a & ", " & "varValueStart:" & varValueStart
if varValueEnd ≠ -1 then set a to a & ", " & "varValueEnd:" & varValueEnd
set a to "{" & a & "}"
copy a to the end of myList
*)
end repeat
Thanks for reviewing.