You have already got some answers which point you to the point in the docs and throw some concept names at you.
<< _ :: binary-size(mp3_byte_size), id3_tag :: binary >> = mp3
This line splits the input binary into 2 parts, the sound data (which instantly gets dropped) and the id3-tag data which gets bound to id3_tag.
<< "TAG", title :: binary-size(30),
artist :: binary-size(30),
album :: binary-size(30),
year :: binary-size(4),
_rest :: binary >> = id3_tag
This splits the tag data up even further.
It matches in order to the sequence of bytes resembling the UTF-8 sequence “TAG”, 3 30 byte sequences and a 4 byte long sequence. The remainder of the tag data is then dropped.
The fixed length sequences are bound to title, artist, album and year.
As those individual fields are “fixed length”, they have to be filled with something in the binary blob. Probably due to having its origin in C the 0 byte has been choosen.
You have to strip it using String.trim_trailing/2, eg. String.trim_trailing(title, <<0>>)






















