Skip to content

Instantly share code, notes, and snippets.

@jneen
Last active September 25, 2022 17:28
Show Gist options
  • Select an option

  • Save jneen/2019c9f6910aa1bcaa646a99e1eaf1b9 to your computer and use it in GitHub Desktop.

Select an option

Save jneen/2019c9f6910aa1bcaa646a99e1eaf1b9 to your computer and use it in GitHub Desktop.

Revisions

  1. jneen revised this gist Sep 25, 2022. No changes.
  2. jneen revised this gist Sep 25, 2022. No changes.
  3. jneen revised this gist Sep 25, 2022. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion ableton_timestamps.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    #!/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
    @@ -14,6 +17,6 @@ end
    RUBY
    )"

    gzip -d <"$file" |\
    gzip -d <"$FILE" |\
    xmllint --xpath '//AudioClip/CurrentStart | //AudioClip/Name' - |\
    ruby -ne "$SCRIPT"
  4. jneen created this gist Sep 25, 2022.
    19 changes: 19 additions & 0 deletions ableton_timestamps.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/usr/bin/env bash

    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"