Skip to content

Instantly share code, notes, and snippets.

@peterzen
Last active October 24, 2018 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterzen/0f54d665589d620a8cd85b84338da6ae to your computer and use it in GitHub Desktop.
Save peterzen/0f54d665589d620a8cd85b84338da6ae to your computer and use it in GitHub Desktop.
Extracts locators from an Ableton ALS file and moves them by a specified time offset. (Useful when merging Live projects.)
#!/bin/bash
ALS=$1
export TIME_VALUE_OFFSET=$2
export ID_OFFSET=$3
if [ "$ALS" == "" -o "$TIME_VALUE_OFFSET" == "" -o "$ID_OFFSET" == "" ]; then
echo "$0 <liveset.als> <locator time offset (bars)> <locator ID offset>"
exit
fi
if [ ! -f $ALS ]; then
echo "$ALS not found"
exit 1
fi
gzip -cd $ALS | \
xmllint --xpath '/Ableton/LiveSet/Locators/Locators' - | \
perl -n -e 'if(/Time Value="(\d+)"\//){ $val=($1+(($ENV{TIME_VALUE_OFFSET}+0)*4)); print " <Time Value=\"$val\"/>\n"} elsif(/<Locator Id="(\d+)">/){ $id=($1+($ENV{ID_OFFSET})); print " <Locator Id=\"$id\">\n" } else { print $_ }' | \
xmllint --format -
echo
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment