Last active
October 24, 2018 01:58
-
-
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.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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