IPB

Welcome Guest ( Log In | Register )

> Notice!

Please take a minute to check our Frequently Asked Questions. Use Search to reveal possible related topics.

Also make sure you've read the Forum Guidelines before posting in this forum.

 
Reply to this topicStart new topic
> Problem with appending COMMENT field with letters
stevehero
post Jan 10 2012, 18:47
Post #1


Member


Group: Full Members
Posts: 564
Joined: 3-December 10
From: Ireland
Member No.: 13334
Mp3tag Version: 2.63



I'm having problems when I have letters in the COMMENT field and I want to append the INITIALKEY field into it. If the COMMENT field contains numbers it works fine but with letters it deletes them. What i have is:

Before (Works fine):
INITIALKEY: 4A
COMMENT: 5

Result:

INITIALKEY: 4A
COMMENT: 4A - 5

Before (Does NOT work):
INITIALKEY: 4A
COMMENT: ANY TEXT HERE

Result:
INITIALKEY: 4A
COMMENT: 4A
[Notice it deletes 'ANY TEXT HERE']

Im using the following actions:
Name of action group: For&mat#INITIALKEY Key to Camelot Notation

Action #1:
Action type: Replace
Field: INITIALKEY
Original: B Major
Replace with: 1B
[ ] only as whole word
[ ] case-sensitive comparison


>>>>>>>Action #1 - #24 change keys to Camelot Notation>>>>>>>>

Action #25:
Action type: Format value
Field: COMMENT
Formatstring: %initialkey% - %comment%

Action #26:
Action type: Replace with regular expression
Field: COMMENT
Regular expression: ^\s+-\s+$|\s+-\s+$|\s+-\s+\d{1,2}[A-B]\s+-\s+$|\s+-\s+\d{1,2}[A-B]$|^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)
Replace matches with: $1$2
[ ] case-sensitive comparison

I've tried using it without action #26 which just cleans up the COMMENT field but it still deletes text and not numbers.

I was just wondering what workaround I could use for action #25?


--------------------
▶✚♬ ═‎​ ♡
Go to the top of the page
 
+Quote Post
JJ Johnson
post Jan 10 2012, 19:06
Post #2


Member


Group: Full Members
Posts: 885
Joined: 18-April 05
Member No.: 1742
Mp3tag Version: 2.63



I just tried it and your action #25 works fine for me. I used the exact same field names and values.

What happens if you execute it alone, without the prior 24 actions in the group?
Go to the top of the page
 
+Quote Post
stevehero
post Jan 10 2012, 19:56
Post #3


Member


Group: Full Members
Posts: 564
Joined: 3-December 10
From: Ireland
Member No.: 13334
Mp3tag Version: 2.63



QUOTE (JJ Johnson @ Jan 10 2012, 18:06) *
I just tried it and your action #25 works fine for me. I used the exact same field names and values.

What happens if you execute it alone, without the prior 24 actions in the group?

yes, Sorry I should of mentioned I tested it on its own and it works just fine. I Have also tried separating the actions with no joy.

I have placed the attached format action group above the replace and reg exp action group in the action list tree. (See attached).

I'm not sure if its a bug in the programme or what??
Attached thumbnail(s)
Attached Image
 

Attached File(s)
Attached File  For_mat_INITIALKEY_Key_to_Camelot_Notation__1_.mta ( 55bytes ) Number of downloads: 65
Attached File  For_mat_INITIALKEY_Key_to_Camelot_Notation__2_.mta ( 2.67K ) Number of downloads: 75
 


--------------------
▶✚♬ ═‎​ ♡
Go to the top of the page
 
+Quote Post
JJ Johnson
post Jan 10 2012, 20:21
Post #4


Member


Group: Full Members
Posts: 885
Joined: 18-April 05
Member No.: 1742
Mp3tag Version: 2.63



From a debugging standpoint, if you haven't done it already, see what you have if you end the action group after action #24. Are you certain that the INITIALKEY and COMMENT fields contain the values that you think they do going into action #25? Particularly the COMMENT field, given the behavior that you describe.

If indeed it's a program bug and the execution of the 20+ actions in one action group could have something to do with it, try breaking the group down into several logical parts.
Go to the top of the page
 
+Quote Post
JJ Johnson
post Jan 10 2012, 20:41
Post #5


Member


Group: Full Members
Posts: 885
Joined: 18-April 05
Member No.: 1742
Mp3tag Version: 2.63



I took your long action group, and replaced the last action with the one that combines the fields.

Action type: Format value
Field: COMMENT
Format string: %initialkey% - %comment%

And it still works as expected on my system. Could it have something to do with the unicode characters? Does it fail when the replaced strings do not contain one of these?

This post has been edited by JJ Johnson: Jan 10 2012, 20:42
Go to the top of the page
 
+Quote Post
stevehero
post Jan 11 2012, 03:13
Post #6


Member


Group: Full Members
Posts: 564
Joined: 3-December 10
From: Ireland
Member No.: 13334
Mp3tag Version: 2.63



QUOTE (JJ Johnson @ Jan 10 2012, 19:41) *
I took your long action group, and replaced the last action with the one that combines the fields.

Action type: Format value
Field: COMMENT
Format string: %initialkey% - %comment%

And it still works as expected on my system. Could it have something to do with the unicode characters? Does it fail when the replaced strings do not contain one of these?

I have found the problem! Silly me. I have the following action which is above my new action which strips the comment field if it doesn't start with a digit as I always format my COMMENT tag like '4A - 5' 4A being the Camelot Notation and the 5 the rating of the track.

Action type: Replace with regular expression
Field: COMMENT
Regular expression: ^[^\d]+.+
Replace matches with:
[ ] case-sensitive comparison

So for anyone out there who wants to change the INITIALKEY tag from F♯ Major to 2B and append it to the start of the COMMENT tag then here is the working action.

Name of action group: For&mat#INITIALKEY Key to Camelot Notation

Action #1:
Action type: Replace
Field: INITIALKEY
Original: B Major
Replace with: 1B
[ ] only as whole word
[ ] case-sensitive comparison


Action #2:
Action type: Replace
Field: INITIALKEY
Original: F♯ Major
Replace with: 2B
[ ] only as whole word
[ ] case-sensitive comparison


Action #3:
Action type: Replace
Field: INITIALKEY
Original: D♭ Major
Replace with: 3B
[ ] only as whole word
[ ] case-sensitive comparison


Action #4:
Action type: Replace
Field: INITIALKEY
Original: A♭ Major
Replace with: 4B
[ ] only as whole word
[ ] case-sensitive comparison


Action #5:
Action type: Replace
Field: INITIALKEY
Original: E♭ Major
Replace with: 5B
[ ] only as whole word
[ ] case-sensitive comparison


Action #6:
Action type: Replace
Field: INITIALKEY
Original: B♭ Major
Replace with: 6B
[ ] only as whole word
[ ] case-sensitive comparison


Action #7:
Action type: Replace
Field: INITIALKEY
Original: F Major
Replace with: 7B
[ ] only as whole word
[ ] case-sensitive comparison


Action #8:
Action type: Replace
Field: INITIALKEY
Original: C Major
Replace with: 8B
[ ] only as whole word
[ ] case-sensitive comparison


Action #9:
Action type: Replace
Field: INITIALKEY
Original: G Major
Replace with: 9B
[ ] only as whole word
[ ] case-sensitive comparison


Action #10:
Action type: Replace
Field: INITIALKEY
Original: D Major
Replace with: 10B
[ ] only as whole word
[ ] case-sensitive comparison


Action #11:
Action type: Replace
Field: INITIALKEY
Original: A Major
Replace with: 11B
[ ] only as whole word
[ ] case-sensitive comparison


Action #12:
Action type: Replace
Field: INITIALKEY
Original: E Major
Replace with: 12B
[ ] only as whole word
[ ] case-sensitive comparison


Action #13:
Action type: Replace
Field: INITIALKEY
Original: A♭ Minor
Replace with: 1A
[ ] only as whole word
[ ] case-sensitive comparison


Action #14:
Action type: Replace
Field: INITIALKEY
Original: E♭ Minor
Replace with: 2A
[ ] only as whole word
[ ] case-sensitive comparison


Action #15:
Action type: Replace
Field: INITIALKEY
Original: B♭ Minor
Replace with: 3A
[ ] only as whole word
[ ] case-sensitive comparison


Action #16:
Action type: Replace
Field: INITIALKEY
Original: F Minor
Replace with: 4A
[ ] only as whole word
[ ] case-sensitive comparison


Action #17:
Action type: Replace
Field: INITIALKEY
Original: C Minor
Replace with: 5A
[ ] only as whole word
[ ] case-sensitive comparison


Action #18:
Action type: Replace
Field: INITIALKEY
Original: G Minor
Replace with: 6A
[ ] only as whole word
[ ] case-sensitive comparison


Action #19:
Action type: Replace
Field: INITIALKEY
Original: D Minor
Replace with: 7A
[ ] only as whole word
[ ] case-sensitive comparison


Action #20:
Action type: Replace
Field: INITIALKEY
Original: A Minor
Replace with: 8A
[ ] only as whole word
[ ] case-sensitive comparison


Action #21:
Action type: Replace
Field: INITIALKEY
Original: E Minor
Replace with: 9A
[ ] only as whole word
[ ] case-sensitive comparison


Action #22:
Action type: Replace
Field: INITIALKEY
Original: B Minor
Replace with: 10A
[ ] only as whole word
[ ] case-sensitive comparison


Action #23:
Action type: Replace
Field: INITIALKEY
Original: F♭ Minor
Replace with: 11A
[ ] only as whole word
[ ] case-sensitive comparison


Action #24:
Action type: Replace
Field: INITIALKEY
Original: D♭ Minor
Replace with: 12A
[ ] only as whole word
[ ] case-sensitive comparison


Action #25:
Action type: Format value
Field: COMMENT
Formatstring: %initialkey% - %comment%

Action #26:
Action type: Replace with regular expression
Field: COMMENT
Regular expression: ^\s+-\s+|^\s+-\s+$|\s+-\s+$|\s+-\s+\d{1,2}[A-B]\s+-\s+$|\s+-\s+\d{1,2}[A-B]$|^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)
Replace matches with: $1$2
[ ] case-sensitive comparison


--------------------
▶✚♬ ═‎​ ♡
Go to the top of the page
 
+Quote Post
DetlevD
post Jan 11 2012, 08:26
Post #7


Member


Group: Full Members
Posts: 4880
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.63



QUOTE (stevehero @ Jan 11 2012, 03:13) *
...
Action #26:
Action type: Replace with regular expression
Field: COMMENT
Regular expression: ^\s+-\s+|^\s+-\s+$|\s+-\s+$|\s+-\s+\d{1,2}[A-B]\s+-\s+$|\s+-\s+\d{1,2}[A-B]$|^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)
Replace matches with: $1$2
[ ] case-sensitive comparison

Please explain, what is the purpose of Action #26 and how does it work?

If you want to detect a 'Camelot string' then you can use this regular expression:
((?:[1-9]|1[0-2])[AB])

Be aware that you fill the tag-field INITIALKEY with bad data, when filling it with a 'Camelot string'.
The standard rules for ID3v2.3 and ID3v2.4 defines the frame TKEY as:
TKEY
The 'Initial key' frame contains the musical key in which the sound starts. It is represented as a string with a maximum length of three characters. The ground keys are represented with "A","B","C","D","E", "F" and "G" and halfkeys represented with "b" and "#". Minor is represented as "m". Example "Cbm". Off key is represented with an "o" only.

It would be a good practical advice to save already existing 'musical key string' into a user-defined backup tag-field before overwriting the tag-field INITIALKEY with 'bad data'.

DD.20120111.0854.CET

This post has been edited by DetlevD: Jan 11 2012, 08:52


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
stevehero
post Jan 12 2012, 18:24
Post #8


Member


Group: Full Members
Posts: 564
Joined: 3-December 10
From: Ireland
Member No.: 13334
Mp3tag Version: 2.63



QUOTE (DetlevD @ Jan 11 2012, 07:26) *
Please explain, what is the purpose of Action #26 and how does it work?

Once the format has been done the following cleans up the COMMENT tag.

^\s+-\s+|^\s+-\s+$|\s+-\s+$|\s+-\s+\d{1,2}[A-B]\s+-\s+$|\s+-\s+\d{1,2}[A-B]$|^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)

^\s+-\s+ deletes 'startofstring'whitespace'-'whitespace' if only COMMENT is present.
^\s+-\s+$ deletes 'startofstring'whitespace'-'whitespace'endofstring' if both COMMENT and INITIALKEY tag are empty.
\s+-\s+$ deletes 'whitespace'-'whitespace'endofstring' if only INITIALKEY is present.
\s+-\s+\d{1,2}[A-B]\s+-\s+$ removes the extra INITIALKEY and 'whitespace'-'whitespace' after format from end of string.
\s+-\s+\d{1,2}[A-B]$ same sort of thing basically only just the INITIALKEY from end of string.
^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+) captures and sorts the COMMENT tag the way it should be formatted.

QUOTE (DetlevD @ Jan 11 2012, 07:26) *
If you want to detect a 'Camelot string' then you can use this regular expression:
((?:[1-9]|1[0-2])[AB])

How is broken down?

QUOTE (DetlevD @ Jan 11 2012, 07:26) *
Be aware that you fill the tag-field INITIALKEY with bad data, when filling it with a 'Camelot string'.
The standard rules for ID3v2.3 and ID3v2.4 defines the frame TKEY as:
TKEY
The 'Initial key' frame contains the musical key in which the sound starts. It is represented as a string with a maximum length of three characters. The ground keys are represented with "A","B","C","D","E", "F" and "G" and halfkeys represented with "b" and "#". Minor is represented as "m". Example "Cbm". Off key is represented with an "o" only.

So:
A sharp minor is A#m
A flat offkey is Abo

Correct?


--------------------
▶✚♬ ═‎​ ♡
Go to the top of the page
 
+Quote Post
DetlevD
post Jan 12 2012, 19:49
Post #9


Member


Group: Full Members
Posts: 4880
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.63



QUOTE (stevehero @ Jan 12 2012, 18:24) *
Once the format has been done the following cleans up the COMMENT tag. ...

stevehero, thank you for the effort to describe the regular expression so colourful.
Still it is not clear to me how the content of the COMMENT tag-field looks like, i. e. the different variations of text content, what the regexp should handle.
It seems to be a very special case for your own purposes?
Can you provide some samples to let me understand what the big regular expression can resolve?

QUOTE (stevehero @ Jan 12 2012, 18:24) *
A sharp minor is A#m
A flat offkey is Abo
Correct?

I understand the term 'off key', stored in tag-field INITIALKEY as the single letter 'o', this way:
The related sound has nothing to do with the musical theory of western music and their melody scales.
The sound is simply off from any key.

DD.20120112.1950.CET


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
stevehero
post Jan 16 2012, 20:58
Post #10


Member


Group: Full Members
Posts: 564
Joined: 3-December 10
From: Ireland
Member No.: 13334
Mp3tag Version: 2.63



QUOTE (DetlevD' date='Jan 12 2012, 18:49) *
stevehero, thank you for the effort to describe the regular expression so colourful.
Still it is not clear to me how the content of the COMMENT tag-field looks like, i. e. the different variations of text content, what the regexp should handle.
It seems to be a very special case for your own purposes?
Can you provide some samples to let me understand what the big regular expression can resolve?

It changes the COMMENT field from:

12A - 12A - Any word character TO (NEED REG EXP TO MATCH THIS)
12A - Any word character (REPLACE WITH '$1$2')

^(\d{1,2}[A-B]\s+-\s+)\d{1,2}[A-B]\s+-\s+(\w+)
Text representation of regular Exp:
^(12A - )12A - (Any word character)


^ Anchors search to start of string.
( Start capture no#1.
\d{1,2}[A-B]\s+-\s+ finds '1A - '
)
End capture no#1.
\d{1,2}[A-B]\s+-\s+ finds '1A - '.
( Start capture no#2.
\w+ Captures word characters.
) End capture no#2.

QUOTE (DetlevD' date='Jan 12 2012, 18:49) *
I understand the term 'off key', stored in tag-field INITIALKEY as the single letter 'o', this way:
The related sound has nothing to do with the musical theory of western music and their melody scales.
The sound is simply off from any key.

I know:
A sharp minor is A#m

But how is:
A sharp major represented?





--------------------
▶✚♬ ═‎​ ♡
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 28th August 2014 - 00:00