vorbis titlestring patch for xmms
---------------------------------

This patch should mostly accomplish the following:

1. Allow specifying arbitrary tags to be displayed as the xmms title.
2. Display tags depending on the occurrence of this/other tag/s.
3. Somehow display all occurrences of a tag. (should be configurable)
*new*
4. Let one edit *all* comment fields in the file, even non-standard
   ones and multiple occurrences of a single one.

Actually it does a little bit more than that, scroll down to see a more
detailed explanation of the patch.



how to use the patched xmms version
-----------------------------------

1. display arbitrary tags

The only special character in the xmms title format is the percent sign
'%', so it is in my patch. There are two ways to specify a tag that should
be displayed. The (old) one with one character abbreviations is not
explained here. However, the other way might need some explanation.
To specify a certain tag, that should be displayed, its name is wrapped in
'=' after a '%', i.e. %=<tagname>=. The equal sign is the only one from
ASCII 0x20 to 0x7D that is not allowed and used to denote the end of a
tagname (see /usr/share/doc/libvorbis-dev/v-comment.html of your libvorbis
installation). I introduced the starting '=' to be able to distinguish
between written out tagnames and the (old) abbreviations, and also because
'[' are allowed in tagnames but here used for conditional tag displaying
(see below).

Examples: 1. "%p - %t"                                      (the short way)
         1'. "%=artist= - %=title="                         (the long way)
          2. "%=artist= - %=album=: %.2n. %t  (%=version=)" (mixed)

(Note that precision only works on abbreviated tagnames, %.2=tracknumber=
will mostly not give the desired result.)


2. conditional tag displaying

To display a certain tag depending on the occurrence of another or the same
tag, put the condition in a %[...?...:...] which should have the same
meaning as in C. The tagname that should trigger the output has to be
written out for now and again, it must be put into '='s followed by a '?'.

Examples:  1. "%=artist=%[=album=? - %=album=:]: %=title="
           2. "%[=artist=?%p :]%[=album=? - %a :]: %n. %t%[=version=? (%=version=): (%=date=)]"
           3. "%[=artist=?%[=album=?%=artist= - %=album=:%=artist=]:] %=title="

       or 1'. "%p%[ =album= ? - %a:]: %t"

Everything between the '%[' and the next '=' for the tag to test on, is
simply ignored. Then, everything between this equal sign and the next one
is treated as this tags name. From the '?' to the next ':' goes the
titlestring that should be displayed if this tag exists; everything after
that to the ending ']' is displayed if it doesn't. Even multiple
conditionals should be possible.


3. multiple tags with the same name

If more than one tag with a certain tagname is present, the configure
dialog allows you to specify strings to concatenate all these tags with.
The "normal" string is used to concatenate all from the first to the second
to last tag. Consequently the "last" string is used for the last occurrence
of this tag. MAKE SURE to put your strings into quotes or double quotes
since the first and last character is simply ignored.
As an example, take the strings to be the following:
Normal glue string: ", "
Last glue string: " and "
(again: include the quotes!)
and your vorbis file has the following artist tags:
artist=Roger Sanches
artist=N'Dea Davenport
artist=Armand Van Helden 
then it would be displayed (if you want) as:
Roger Sanches, N'Dea Davenport and Armand Van Helden

Note that this works only for "written out" tagnames, i.e. the one that are
put into =...= (see 1. above).



more information about this patch
---------------------------------

This patch adds a new function to Input/vorbis/vorbis.c which is called
vorbis_get_titlestring and is located at the end of the file. It is used
instead of xmms_get_titlestring if 'Override default title' in the plugins
config dialog is checked. It's mainly copy and pasted from
xmms_get_titlestring and modified to allow tagnames instead of simple one
character abbreviations.  Scroll down to look for bugs/features/mistakes
and inform me. Better yet, fix it. ;)

Aside from the imho more sophisticated titlestring displaying this patch
also does:
* a somehow advanced tag editor, which lets you edit all tags, even
  non-standard and multiple ones.
  This is enabled by defining VORBIS_ADV_EDIT at compile time or by
  commenting out the appropriate lines in the newly introduced
    Input/vorbis/fileinfo.h.
* a not documented, but already included feature is
  ALL_VORBIS_TAGS, which gives you a list of (almost?) all comment fields
  as specified in /usr/share/doc/libvorbis-dev/v-comment.html.
  This might be obsoleted by VORBIS_ADV_EDIT, which does a more flexible
  job on this, however, it is enabled in the same way as above.

There might be some bugs in it and not properly checked ranges, but I tried
my best to fix it.
So this patch comes WITHOUT ANY WARRANTY and USE IT AT YOUR OWN RISK.

This patch is against the cvs snapshot as stated in the filename (2003-10-28),
not the release version of xmms, although it might work there also. I try
to update it as often as I can.



todo
----
* make the VORBIS_ADV_EDIT into a configurable option
* substitute the fixed 256byte buffers by dynamical ones to get the full
  advantage of vorbis' 2^32-1 byte long vorbis user comments.
* clarify the usage maybe?
* simplify the usage??
* something else???



thanks to
---------
* Jens Z. Burkal for providing the multiple tag feature



contact
-------
Stefan Bender <oraqhf@gmx.net>

Use and enjoy it, /Stefan.
