Skip to content

Instantly share code, notes, and snippets.

@jneen
Last active September 25, 2022 17:28
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 jneen/2019c9f6910aa1bcaa646a99e1eaf1b9 to your computer and use it in GitHub Desktop.
Save jneen/2019c9f6910aa1bcaa646a99e1eaf1b9 to your computer and use it in GitHub Desktop.
extract clip start times from an ableton project file in 30fps format at 225bpm
#!/usr/bin/env bash
# .als file
FILE="$1"; shift
SCRIPT="$(cat <<RUBY
\$_.scan(%r[<CurrentStart Value="(.*?)"/><Name Value="(.*?)"/>]) do |start, name|
frame = (start.to_f * 8).round
seconds, frame = frame.divmod(30)
minutes, seconds = seconds.divmod(60)
hours, minutes = minutes.divmod(60)
stamp = [hours, minutes, seconds, frame].map { |n| sprintf("%02d", n) }.join(':')
puts "#{stamp} #{name}"
end
RUBY
)"
gzip -d <"$FILE" |\
xmllint --xpath '//AudioClip/CurrentStart | //AudioClip/Name' - |\
ruby -ne "$SCRIPT"
@jneen
Copy link
Author

jneen commented Sep 25, 2022

225 bpm means 32nd notes line up exactly with 30fps frames. 30fps * 60 seconds per minute / 8 frames per beat = 225bpm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment