Skip to main content

Topic: Changes Made to TAG.EXE (Read 137445 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #50
Thinking about it, I think this will be because Tag understands MP3 files, but has no idea how to decypher TAK files (or OptimFrog, WavPack, and maybe more).  Part of the extended information involves writing the duration of the track, and Tag can't retrieve that as it doesn't know how to read the header.

That said, I believe using -1 for the duration is valid (certainly for streaming files), so I may see if I can get Tag to use -1 for the duration if it can't decypher the format, and use the meta data info that it should surely know about.

I'll add it to my list of crap to stop me from doing proper work... 

Edit: FYI I have confirmed this.  If Tag cannot obtain a duration it does not write the line at all.  I'll report back here if I can make the change.
  • Last Edit: 02 May, 2007, 05:16:50 AM by Synthetic Soul
I'm on a horse.

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #51
OK, you can give Tag 2.0.52 a go.

This version should write #EXTINF for any file.  If it doesn't understand the file type it will use -1 as the duration.

Edit: Removed beta status.
  • Last Edit: 04 May, 2007, 03:04:51 AM by Synthetic Soul
I'm on a horse.

Changes Made to TAG.EXE
Reply #52
I use tag.exe to write the correct tags based on filenames with:

Code: [Select]
tag --auto --chreplace *.flac


I have changed the configuration file to mij needs (see below).
The autorenaming from ^ to ? works correct.
But somehow the conversion from ; to : doesn's work.
Must the ; be escaped or something?

Code: [Select]
# Specify character replacement for tagging
# note: space is separator
[CharReplacementForTag]
^ ?
; :
netjukebox - the flexible media share
http://www.netjukebox.nl

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #53
I can confirm that this is the case, but can't immediately see why.

FYI: prefixing the semicolon works, so a replacement of "@; :" will convert "@;" to ":"; however ";@ :" does not work as expected.

It seems to be an issue with it beginning with ";".  The ListSeparator is "; ", but I've checked in a hex editor and "^;^" results in 3F 3B 3F ("?;?"), not 3F 00 3F, as you would hope.

Dunno...

Here's the key code (taken from Tag.cpp) I believe (NB: swap is done in misc.cpp's ReplaceCharactersForTag):

Code: [Select]
case MCharReplaceTag:   // settings under [CharReplacementForTag]
    if ( (ReplaceTag->OldChars = (char **)realloc ( ReplaceTag->OldChars, sizeof (*ReplaceTag->OldChars) * (ReplaceTag->CharCount + 1) )) == NULL ) {
    fprintf ( stderr, "load_config: Memory allocation failed.\n" );
    exit (1);
    }
    if ( (ReplaceTag->NewChars = (char *)realloc ( ReplaceTag->NewChars, ReplaceTag->CharCount + 1 )) == NULL ) {
    fprintf ( stderr, "load_config: Memory allocation failed.\n" );
    exit (1);
    }
    p = temp;
    while ( *p && *p != ' ' ) p++;
    if ( (ReplaceTag->OldChars[ReplaceTag->CharCount] = (char *)malloc ( p - temp + 1 )) == NULL ) {
    fprintf ( stderr, "load_config: Memory allocation failed.\n" );
    exit (1);
    }
    if ( p > temp ) {
    strncpy ( ReplaceTag->OldChars[ReplaceTag->CharCount], temp, p-temp );
    }
    ReplaceTag->OldChars[ReplaceTag->CharCount][p-temp] = '\0';
    if ( *p == ' ' ) p++;
    ReplaceTag->NewChars[ReplaceTag->CharCount] = *p;
    ReplaceTag->CharCount++;
    break;
I'm on a horse.

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #54
Doh.

Just seen the real culprit just before that code in Tag.cpp:

Code: [Select]
    while ( fgets_clean ( temp, sizeof (temp), fp ) != EOF ) {
        if ( temp[0] == '\0' || temp[0] == ';' || temp[0] == '#' )  // skip empty lines and comments
            continue;

Not sure how to resolve this.  It's possible to remove the check for ";", but what if people are using them for comment lines?  I don't like to break backward compatibility.  presumably "# :" wouldn't work either.

I can see no way to escape the character.
  • Last Edit: 06 May, 2007, 01:41:37 PM by Synthetic Soul
I'm on a horse.

Changes Made to TAG.EXE
Reply #55
Thanks for the clear explanation.

I understand that you don't wont to break backwards compatibility.
A switch to disable the ; comment could be an option.
But maybe I'm the only one who really needed this feature.
netjukebox - the flexible media share
http://www.netjukebox.nl

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #56
Well, users should really be able to swap any characters they choose.

I'd be tempted to stop ";" being a comment character just in that section. 1.  The initial cfg file uses "#" so users may only think (as I did) that "#" is the only character that can be used (so no-one is using ";"). 2. "#" does not need replacing, as it is a valid filename character, so that can still be used.

If you agree I can easily create 2.0.53b1 and upload for you (and all new full releases will act in this way).
I'm on a horse.

Changes Made to TAG.EXE
Reply #57
If I understood correctly than the ; will still be a comment tag.
But only in the [CharReplacementForTag] section you can use ;

That is really a good solution and still backwards compatible.
So I agree and would like doing some tests with the upcoming tag 2.0.53b1

Thanks for your help.
netjukebox - the flexible media share
http://www.netjukebox.nl

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #58
You understand correctly. You can try 2.0.53b1.

FYI: all I have amended is:

Code: [Select]
if ( temp[0] == '\0' || (temp[0] == ';' && mode != MCharReplaceTag) || temp[0] == '#' )  // skip empty lines and comments
I'm on a horse.

Changes Made to TAG.EXE
Reply #59
Simply fixes are mostly the best 
Everything seems to work as expected.

If I find something strange I will post it here.
I don't think that will happen with such a straightforward fix.

Thanks again.
netjukebox - the flexible media share
http://www.netjukebox.nl

Changes Made to TAG.EXE
Reply #60
I have done some test the last days with tag 2.0.53b1 and everything related to the ; renaming worked perfectly.

With double albums I discovered that tag.exe gave the album tag a cd number like below:

Code: [Select]
Filename                      Album tag
101 - Album name.extension    Album name (CD 1)
102 - Album name.extension    Album name (CD 1)
201 - Album name.extension    Album name (CD 2)
202 - Album name.extension    Album name (CD 2)


Can this behaviour somehow be configured or is this hard coded in the program?
netjukebox - the flexible media share
http://www.netjukebox.nl

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #61
It looks to me as though there is a way to get the value into a Disc tag instead, but I can't work out how. 

The relevant code is in "guess.cpp".

FYI, according to the code %D for Disc is a valid token, although it's not documented in the CFG file.

I can't work out from the code what you're supposed to do to get the disc tag instead of it appending " (CD x)" to the album name.

Edit:  Got it. I don't know what I was doing wrong.

Code: [Select]
tag --auto --scheme "%L\%D%N - %T" "204 - Track name.wv"

Code: [Select]
Tag - Automatic Tag from filename
Copyright (c) 2002-2003 Case.  Minor additions by Neil Popham, 2004-2007
Version 2.0.53b1, Compiled 2007-05-07

C:\Documents and Settings\Neil\Desktop\204 - Track name.wv
Tag:     Generated from name
Title:   Track name
Artist:
Album:   Desktop
Year:
Track:   04
Genre:
Comment:
Disc=2
APE v2.0 tag written.
  • Last Edit: 11 May, 2007, 12:20:49 PM by Synthetic Soul
I'm on a horse.

Changes Made to TAG.EXE
Reply #62
I don't want to be a pain in the arse 
But still I found a problem with tag.

Code: [Select]
tag --auto --chreplace --scheme "%A\%Y - %L\%D%N - %T" *.flac

When using the command line like this the "Vorbis comment" block is written as below:

Code: [Select]
METADATA block #2
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 316
  vendor string: reference libFLAC 1.1.4 20070213
  comments: 11
    comment[0]: REPLAYGAIN_REFERENCE_LOUDNESS=89.0 dB
    comment[1]: REPLAYGAIN_TRACK_GAIN=-6.36 dB
    comment[2]: REPLAYGAIN_TRACK_PEAK=0.98138428
    comment[3]: REPLAYGAIN_ALBUM_GAIN=-6.48 dB
    comment[4]: REPLAYGAIN_ALBUM_PEAK=0.98852539
    comment[5]: Disc=2
    comment[6]: TITLE=Hatoa
    comment[7]: ARTIST=Bonobo
    comment[8]: ALBUM=Days to come
    comment[9]: TRACKNUMBER=07
    comment[10]: DATE=2006
METADATA block #3
  type: 1 (PADDING)
  is last: true
  length: 3820


The %D is written as "Disc", I think that this must be "DISCNUMBER" for "Vorbis comment".
When using the same line "%A\%Y - %L\%D%N - %T" in the [Schemes] section of tag.cfg it doesn't work at all.
netjukebox - the flexible media share
http://www.netjukebox.nl

  • vasya_pupkin
  • [*][*][*]
  • Banned
Changes Made to TAG.EXE
Reply #63
I have a feature request. Tag currently doesn't work properly with tracknumbers like "01/19" when renaming. It just renames file to "01-19 (something)". It would be better if it would rename file to "01 (something)" in this case.

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #64
The %D is written as "Disc", I think that this must be "DISCNUMBER" for "Vorbis comment".
When using the same line "%A\%Y - %L\%D%N - %T" in the [Schemes] section of tag.cfg it doesn't work at all.
I can easily (I think) change it to write Discnumber for all formats.  I'm tempted by this, as IIRC it is the suggested filed name for that data.  I'm confused why foobar uses Disc now, when I thought that it had previously moved from Disc to Discnumber.

The code that creates the disc tag has the comment "// quick hack".  I'm not confident about copying this to the other functions, that deal with the schemes and auto tagging.

I have a feature request. Tag currently doesn't work properly with tracknumbers like "01/19" when renaming. It just renames file to "01-19 (something)". It would be better if it would rename file to "01 (something)" in this case.
I'm sorry, but this is beyond me.
I'm on a horse.

  • vasya_pupkin
  • [*][*][*]
  • Banned
Changes Made to TAG.EXE
Reply #65
I'm sorry, but this is beyond me.

Ok, can you please try this patch? I was unable to build all this mess because of libFLAC.

Code: [Select]
--- guess-old.cpp    2005-06-12 20:37:10.000000000 +0400
+++ guess.cpp    2007-05-12 03:11:51.981339500 +0400
@@ -678,6 +678,7 @@
     char    temp    [_MAX_PATH * 2 + 1];
     char    tempname[4096];
     char*   src   = NULL;
+    char*   sl;
     char*   f;
     size_t  s_pos = 0;
     size_t  i;
@@ -713,8 +714,14 @@
         }

         if ( src != NULL ) {
-            if ( src == TagValue ( APE_TAG_FIELD_TRACK, Info ) && (strlen (src) == 1) ) {
-                *f++ = '0';
+            if ( src == TagValue ( APE_TAG_FIELD_TRACK, Info ) ) {
+                if (strlen (src) == 1) {
+                    *f++ = '0';
+                }
+                sl = strchr ( src, '/' );
+                if ( sl != NULL ) {
+                  strncpy ( sl, '\0', 1 );
+                }
             }

             f += sprintf ( f, "%s", src );

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #66
Ok, can you please try this patch? I was unable to build all this mess because of libFLAC.
Your patch causes an application error.

NB: I have written a guide regarding how to set up the source structure to build Tag.  I did this ages ago, as it took me so long to just work out how to compile it when I made my first changes; it may be obvious to you.  The guide can be found here:

http://www.synthetic-soul.co.uk/tag/setup.txt

It seems pretty f***ed up that you, as a C programmer, should be asking me, a non-C programmer, to make changes.  If you know C and want changes, do it!

As I've said many times now, I find my lack of knowledge frustrating, and trying to action people's requests is now just pissing me off.  I wish I'd stopped at version 2.0.40 sometimes.  I rarely even use Tag, although I do find it very useful to check what foobar is up to.

Sorry, don't mean to rant, and it's not aimed at you specifically.

Edit: Hang on, now I bother to look at your code, you never end up doing anything with sl do you?
  • Last Edit: 12 May, 2007, 03:46:25 AM by Synthetic Soul
I'm on a horse.

  • vasya_pupkin
  • [*][*][*]
  • Banned
Changes Made to TAG.EXE
Reply #67
Your patch causes an application error.

Oops...

Quote
It seems pretty f***ed up that you, as a C programmer, should be asking me, a non-C programmer, to make changes.  If you know C and want changes, do it!

I'm not a C programmer. In fact, I don't know C at all. I just analized the code and made a change that could do the thing in theory. But I could mess up something with pointers because I don't know how they work in C.

I will try your guide, maybe it'll help me to find those missing headers libFLAC wants.

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #68
I'm not a C programmer. In fact, I don't know C at all. I just analized the code and made a change that could do the thing in theory. But I could mess up something with pointers because I don't know how they work in C.
Ah, I see.  Seems like we are in the same boat.
I'm on a horse.

  • vasya_pupkin
  • [*][*][*]
  • Banned
Changes Made to TAG.EXE
Reply #69
Your patch causes an application error.

I found why. Replace
Code: [Select]
+                  strncpy ( sl, '\0', 1 );

with
Code: [Select]
+                  strncpy ( sl, "\0", 1 );


How could I do such a stupid mistake?

PS: I spent an hour trying to build it with VS2003, but ended up with nothing. Everything builds but linker shows errors. So, it's again an unverified patch.. Hope it'll work this time..

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #70
That appears to work.

Shouldn't it still pad the number though?


Edit: S'OK, I just changed it to:

Code: [Select]
if ( src == TagValue ( APE_TAG_FIELD_TRACK, Info ) ) {
    sl = strchr ( src, '/' );
    if ( sl != NULL ) {
        strncpy ( sl, "\0", 1 );
    }
    if (strlen (src) == 1) {
        *f++ = '0';
    }
}


2.0.53b2
  • Last Edit: 12 May, 2007, 11:06:54 AM by Synthetic Soul
I'm on a horse.

  • vasya_pupkin
  • [*][*][*]
  • Banned
Changes Made to TAG.EXE
Reply #71
Thank you very much! It works!

  • odyssey
  • [*][*][*][*][*]
Changes Made to TAG.EXE
Reply #72
Ummm, is it possible to avoid printing the copyright notice? Currently it outputs to the screen no matter what.
Can't wait for a HD-AAC encoder :P

  • Synthetic Soul
  • [*][*][*][*][*]
  • Global Moderator
Changes Made to TAG.EXE
Reply #73
I don't think that you can, but I don't think that you need to.  You may want to look at --stdout.

Using that switch you can output the important bits to STDOUT, and leave the header writing to STDERR (IIRC).

E.g.:

Code: [Select]
TAG.EXE --stdout --hideinfo --hidenames file.mp3 > tags.txt
I'm on a horse.

  • A1S
  • [*]
Changes Made to TAG.EXE
Reply #74
Thanks for the tool. Will not prompt, how I can write a cover in a wv-file? Whether it is possible to register separate tags (for example Cover Art (Front) and Cover Art (Back))?