Ableton arrangement locators to QLab markers.

283 views
Skip to first unread message

micpool

unread,
Sep 17, 2021, 10:54:09 AM9/17/21
to QLab
If anyone wants to convert Ableton locators to QLab markers here's a script to do it. There's 1 limitation. The arrangement must have a fixed manual tempo, which is used to convert Ableton's beat based locators to seconds.

You can also adapt the script to get just about any other parameter from an Ableton session file (which is actually just a zipped xml)

--get locators from an Ableton .als file and apply them as markers in the selected cue in QLab
--by Mic Pool
set theloc to (path to desktop)
set thefile to choose file
tell application "Finder"
set r to duplicate thefile to theloc
set the name of r to "temp.zip"
delay 1
open file "temp.zip"
delay 1
set the name of (last item of (sort files of theloc by creation date) as alias) to "temp.xml"
delete file "temp.zip"
delay 1
end tell
set theLocators to {}
set therecord to {}
tell application "System Events"
tell XML file "~/Desktop/temp.xml"
tell XML element "Ableton"
tell XML element "LiveSet"
tell XML element "MasterTrack"
tell XML element "DeviceChain"
tell XML element "Mixer"
tell XML element "Tempo"
set thetempo to value of XML attribute 1 of XML element "Manual"
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
set theLocators to {}
tell application "System Events"
tell XML file "~/Desktop/temp.xml"
tell XML element "Ableton"
tell XML element "LiveSet"
tell XML element "Locators"
tell XML element "Locators"
set theElements to every XML element whose name is "Locator"
repeat with eachelement from 1 to length of theElements
set currentelement to item eachelement of theElements
set end of theLocators to value of XML attribute "Value" of XML element "Time" of currentelement
end repeat
end tell
end tell
end tell
end tell
end tell
end tell
tell application "Finder" to delete file "temp.xml"
tell application id "com.figure53.QLab.4" to tell front workspace
repeat with eachlocator from 1 to (count of theLocators)
set aTime to (item eachlocator of theLocators as real) * (60 / thetempo)
set aRecord to {time:aTime, playCount:1}
set the end of therecord to aRecord
end repeat
set theselected to last item of (selected as list)
set the slice markers of theselected to (get therecord)
end tell

Ableton to Qlab markers.m4v

Kieran Lucas

unread,
Sep 20, 2021, 6:29:43 AM9/20/21
to QLab
Hey Mic,

This looks like a really useful script!

Unfortunately I keep getting the error message "Unable to expand "temp.zip". It is in an unsupported format."

Do I need to structure the files in a specific way in order for the script to run? Should I be selecting the .als file from the Finder, or the .wav, or the whole project? Any pointers greatly appreciated!

Kx

micpool

unread,
Sep 20, 2021, 7:23:09 AM9/20/21
to QLab
I don't understand what you mean by "Should I be selecting the .als file from the Finder, or the .wav, or the whole project?" When you run the script the file you choose should just be a standard .als file, i.e the file that is created/modified when you  Save Live Set (the standard cmd-S save operation) from the file menu in Ableton.

Then it should just work. (Having said that I only have  Ableton Live v9, but I don't think the .als format has changed)

To try and work out what is going on you could do the first steps manually.

Take a duplicate of an .als file and rename it to temp.zip (you will get a dialog asking you to confirm you want to change the extension to .zip)

open the file temp.zip

It should decompress to a file named temp. If it doesn't get info and check that it's a zip archive and your default decompressor is Archive Utility.app (which is the standard Apple app)

rename that file temp.xml and open with textedit and you should get the full xml data structure.

Let me know at what point that is going wrong for you.

Mic

Kieran Lucas

unread,
Sep 20, 2021, 10:45:07 AM9/20/21
to QLab
Got it working!

Was previously selecting the .asd analysis file, not the .als project file.

Really brilliant and useful script - thanks Mic

Bob

unread,
May 13, 2022, 3:22:11 PM5/13/22
to QLab
Hi Mic, I'm trying this script with a file saved in Live 11 and I'm getting the following error: (see screenshot)
Do you have any idea what might cause this error? I'm using a fixed tempo in LIve, I don't really understand what you mean with manual tempo.
Thank you so much for sharing your incredible knowledge!!

Bob



Screenshot 2022-05-13 at 21.02.43.png

Bob

unread,
May 13, 2022, 3:27:12 PM5/13/22
to QLab
aha... if I manually give in the tempo in the script it works!! Great... is that how it is supposed to work? 

Bob

micpool

unread,
May 13, 2022, 3:50:22 PM5/13/22
to QLab

No, it should parse the tempo from the file, i don’t have Ableton 11 to check

Can you post the .als file that is giving that error.?

Mic

Bob

unread,
May 13, 2022, 3:52:11 PM5/13/22
to QLab
Here you go Mic!
Bswan.als

micpool

unread,
May 13, 2022, 5:59:31 PM5/13/22
to QLab
Works fine for me
Mic
markers.mov

micpool

unread,
May 14, 2022, 8:01:38 AM5/14/22
to QLab
Bob,
This is most likely due to the fact that you have your decimal separator set to comma rather than point.
The manual tempo property  in the xml from Ableton is stored as a string. Applescript can only convert it to a real number if it thinks the point in the string is the decimal separator.
Screen Shot 2022-05-14 at 12.58.51.png

Mic

Bob

unread,
May 14, 2022, 4:46:23 PM5/14/22
to QLab
You were absolutely right Mic, when changing the decimal to a point, your script works perfectly! Again thank you!!!!

Maik Waschfeld

unread,
May 15, 2022, 2:54:08 PM5/15/22
to ql...@googlegroups.com
HI Bob,

If you don’t want to change settings in the Preferences pane:

replace:
set thetempo to value of XML attribute 1 of XML element "Manual"

in Mic’s script with:
set thetempo_0 to value of XML attribute 1 of XML element "Manual"
set thetempo to my sub_replace_chars(thetempo_0, ".", ",")

and put the following after the end of Mic’s script:

-- replace characters
-- The following sub-routine can be used to replace specific characters in a string.
-- The sub-routine has three passed parameters: 1) the text to alter, 2) to text to search for, 3) the replacement text
on sub_replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end sub_replace_chars

The result:
thetempo = "100,996223"


With kindest regards…
…Maik Waschfeld

(sent from my MBPro16,2)
also at <mailto:Maik.Wa...@Staatstheater-Stuttgart.de>



-- 
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
--- 
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/882239ce-b6ea-43f4-9303-72d1dcb177den%40googlegroups.com.

Bob

unread,
May 15, 2022, 3:44:45 PM5/15/22
to QLab
Hi Maik,

Thank you so much, it works indeed perfect now. Thank you so much!

What a nice group/community this is. I'm really glad to discover this!

Have a nice evening.

Bob

Maik Waschfeld

unread,
May 15, 2022, 7:12:15 PM5/15/22
to ql...@googlegroups.com
Hi Bob,

Thank you so much, it works indeed perfect now. Thank you so much!

Great!
You’re welcome!

I've figured out another solution, now completely honouring the System Preference’s localisation.
So even if you decide to switch to any localisation, Mic’s script won’t break:

replacing:
set thetempo to value of XML attribute 1 of XML element "Manual"

in Mic’s script with:
set thetempo_0 to value of XML attribute 1 of XML element "Manual"
set loc_decimal to localized string of character 2 of (pi as text)
set thetempo to my sub_replace_chars(thetempo_0, ".", loc_decimal)

and put the before mentioned sub-routine

-- replace characters
-- The following sub-routine can be used to replace specific characters in a string.
-- The sub-routine has three passed parameters: 1) the text to alter, 2) to text to search for, 3) the replacement text
on sub_replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end sub_replace_chars
-- end replace characters

under Mic’s script.


With kindest regards…
…Maik Waschfeld

(sent from my MBPro16,2)
also at <mailto:Maik.Wa...@Staatstheater-Stuttgart.de>


bob hermans

unread,
May 16, 2022, 2:51:28 AM5/16/22
to ql...@googlegroups.com
Even better indeed!! 
Just tested it and it works like a charm.

Thanks again Maik.



You received this message because you are subscribed to a topic in the Google Groups "QLab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qlab/F5Tg83tvH2Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/37A312C9-593D-48DC-9288-ABF9ABD58A8F%40Maik-Waschfeld.de.

Bob

unread,
May 16, 2022, 4:34:06 AM5/16/22
to QLab
He Mic and Maik, i don't want to push my luck, but I'm running into a (maybe similar) problem with Mic's 
"Marker thing" I found on the Facebook group. https://www.facebook.com/1333653473/videos/10225334404770467/
(I post it here because I can't seem to find it here in the group).

As a novice in scripting (or actually even better, just a user of your scripts), I'm actually confused to where the original script is in this workspace. :) But that aside...

When trying it out, I'm running again into something that might be a "comma" thing (see screenshot), but only this time changing the language preference to "point" does not seem to work.

I hope my question makes any sense, I find these scripts so handy, but at the same time my knowledge about them is so limited at the moment that I have not really an idea if I'm asking strange questions. 
Screenshot 2022-05-16 at 10.31.18.png

Maik Waschfeld

unread,
May 16, 2022, 1:35:08 PM5/16/22
to ql...@googlegroups.com
HI Bob,

I changed the subject, so we’re not confusing other readers.

BTW:
is anyone familiar with the different localisations?
Is the US-localisation, the only one to use „.“ period as decimal separator?
Anyone else using different decimal separators?


You’re right with the assumption on localisation-trouble within AppleScript.

The scripts, that actually do the job, are in a second cue list, called „Scripts“.

The first one, Name „Hotkey 1“, cue number „MARKIT“ is the one with the localisation problem.

- add to the beginning:
set loc_decimal to localized string of character 2 of (pi as text)


- replace:
set the post wait of thecue to action elapsed of audiocue

- with:
set actElapsed_0 to (action elapsed of audiocue) as text
set actElapsed to my sub_replace_chars(actElapsed_0, loc_decimal, ".")
set the post wait of thecue to actElapsed


- replace:
set the script source of thecue to "tell application id \"com.figure53.QLab.4\" to tell front workspace" & return & "set thegroup to (first cue whose q number is \"" & thegroupcuenumber & "\")" & return & "stop (cues of thegroup whose q type is \"audio\") " & return & "delay 0.1" & return & "load (first cue whose q number is \"" & thegroupcuenumber & "\")" & " time " & post wait of thecue & return & "set playhead of current cue list to thegroup" & return & "end tell“

- with:
set the script source of thecue to "tell application id \"com.figure53.QLab.4\" to tell front workspace" & return & "set thegroup to (first cue whose q number is \"" & thegroupcuenumber & "\")" & return & "stop (cues of thegroup whose q type is \"audio\") " & return & "delay 0.1" & return & "try" & return & "load (first cue whose q number is \"" & thegroupcuenumber & "\")" & " time " & actElapsed & return & "end try" & return & "set playhead of current cue list to thegroup" & return & "end tell"

In this replacement-snippet, I also added a pair of „try“ and „end try“ as I hate it, when a Script cue fails and I have to Compile the script cue again & again ...

- And adding to the end, below Mic’s last end tell:
-- replace characters
-- The following sub-routine can be used to replace specific characters in a string.
-- The sub-routine has three passed parameters: 1) the text to alter, 2) to text to search for, 3) the replacement text
on sub_replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end sub_replace_chars
-- end replace characters


The second one, Name „Hotkey 2“, cue number „SLICEIT“ has no localisation problem.
but you can replace the „set the script source of eachcue to “ line, if you like,

with:
set the script source of eachcue to "tell application id \"com.figure53.QLab.4\" to tell front workspace" & return & "set thegroup to (first cue whose q number is \"" & thestring & "\")" & return & "set theaudiocue to first item of (cues of thegroup as list )" & return & "set themarkerlist to slice markers of theaudiocue" & return & "stop (cues of thegroup whose q type is \"audio\") " & return & "delay 0.1" & return & "try" & return & "load (first cue whose q number is \"" & thestring & "\")" & " time  (time of (item " & thecount & "of themarkerlist))" & return & "end try" & return & "set playhead of current cue list to thegroup" & return & "end tell"

In this replacement-snippet, I added a pair of „try“ and „end try“, too.


With kindest regards…
…Maik Waschfeld

(sent from my MBPro16,2)
also at <mailto:Maik.Wa...@Staatstheater-Stuttgart.de>


Bob

unread,
May 16, 2022, 2:26:21 PM5/16/22
to QLab
Well Maik, am I lucky that my copy/paste skills are as good as your scripting skills. It makes it pretty easy!!
You guys are great.

Bob


micpool

unread,
May 16, 2022, 2:28:18 PM5/16/22
to QLab
On Monday, May 16, 2022 at 6:35:08 PM UTC+1 Maik.Waschfeld wrote:
BTW:
is anyone familiar with the different localisations?
Is the US-localisation, the only one to use „.“ period as decimal separator?


No, the following countries all use a period as a decimal separator: 

Australia
Bangladesh
Botswana
British West Indies
Cambodia
Canada (when using English)
China
Dominican Republic
Egypt
El Salvador
Estonia
Ethiopia
Ghana
Guatemala
Guyana
Honduras
Hong Kong
India
Ireland
Israel
Jamaica
Japan
Jordan
Kenya
Korea, North
Korea, South
Libya
Liechtenstein
Luxembourg (uses both marks officially)
Macau (in Chinese and English text)
Malaysia
Maldives
Malta
Mexico
Myanmar
Namibia (uses both marks)
Nepal
New Zealand
Nicaragua
Nigeria
Pakistan
Panama
Peru (currency numbers only)
Philippines
Qatar
Saudi Arabia
Singapore
Somalia
Sri Lanka
Switzerland[c]
Syria
Taiwan
Tanzania
Thailand[b]
Uganda
United Arab Emirates
United Kingdom
United States (including insular areas)

Maik Waschfeld

unread,
May 16, 2022, 5:54:32 PM5/16/22
to ql...@googlegroups.com
Hi Mic,

Thanks very much !!!!


With kindest regards…
…Maik Waschfeld

(sent from my MBPro16,2)
also at <mailto:Maik.Wa...@Staatstheater-Stuttgart.de>


--
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.

bob hermans

unread,
May 17, 2022, 7:30:37 AM5/17/22
to ql...@googlegroups.com
Thanks Mic, i will try that tonight! If not, changing the tempo manually in the script per song is also not so much work. :) 
I really like that I can use the live locators!

Bob

Sent from my iPhone

On 14 May 2022, at 14:01, micpool <m...@micpool.com> wrote:

Bob,
--
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to a topic in the Google Groups "QLab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qlab/F5Tg83tvH2Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/6b00f8d1-e7f6-4b85-92dd-70e6121d035an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages