Repeatable Music
The concept of repeatable music is an old thing, most obviously used in video games, where you need to loop the same track over and over. There are a lot of tools and music formats out there to handle this: mod, s3m, it, spc, and so on, are all designed to allow infinitely looping music. It was easy to programmatically loop music with any vintage sound chip: the Commodore 64’s SID, Ad-Lib’s YM3812, SNES SPC700, and so on.
But there’s no clear standard out there for indicating that a piece of rendered music (mp3, ogg, flac, etc) is repeatable.
Alcan is the answer#
Inspired by Andy Church’s mp3play.pl, alcan.lua is a script for the mpv media player that will auto-populate the mpv “A” and “B” loop properties under the following circumstances:
- MP3 comment in the form of: repeat start=X len=Y
- OGG or FLAC properties LOOPSTART/LOOPLENGTH/LOOPEND
- Filesystem xattrs user.alcan.loopa and user.alcan.loopb
If any of the above are detected, the ’l’ key is overridden to mean “enable or disable Alcan-style looping”, with the loop off by default. Using mpv’s --loop-file=inf or --loop alias will also enable Alcan-style looping.
In my view, xattrs are the best solution to this problem since they allow the loop points to be marked without modifying the file. This is important for digital preservationists or situations where the file hash can’t or shouldn’t change.
Cries of “it’s difficult to preserve xattrs” fall on deaf ears in the 21st Century.