getmusicbee.com

General => MusicBee Wishlist => Topic started by: redwing on January 26, 2013, 12:09:31 PM

Title: Split the content of a field to multiple virtual fields
Post by: redwing on January 26, 2013, 12:09:31 PM
Originated from this thread: http://getmusicbee.com/forum/index.php?topic=6719.0

MB's virtual tags offer powerful assistance to managing music library, fulfilling various kinds of needs from users. But it would be nicer if we can do the current "infer and update tags from filename (+ other tags)" function with virtual tags. In other words, that would let users split the content of a field to multiple virtual fields and use them for managing library. For instance, it would instantly address the request of classical music fans to split "work" and "movement" part from title field.

That function would be similar to "guess values" action of MP3tag, but with virtual tags users wouldn't have to constantly update tags manually. Currently additional tagging tools plugin supports a similar function, but it only accepts regular expression which is far from easy for an average user. If this is implemented, MB alone could handle that kind of tagging needs without the assistance of the plugin.

In the thread linked above, I saw a proposed "Split" function for virtual tags. Not sure how it saves the indexed parts of string in other tags, but, for one thing, the function would accept only one delimiter, which is inferior to the current "infer and update tags from filename" function. Probably Steven knows it much better from technical aspect.

Thanks in advance!
Title: Re: Split the content of a field to multiple virtual fields
Post by: Steven on January 27, 2013, 11:43:35 AM
i've done a Split function
$Split(<field>,"search for text",index)

so a field with a value of: "the : smart : fox"
$Split(<field>,":",1) -> the
$Split(<field>,":",2) -> smart
$Split(<field>,":",3) -> fox


Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 11:58:07 AM
i've done a Split function
$Split(<field>,"search for text",index)

so a field with a value of: "the : smart : fox"
$Split(<field>,":",1) -> the
$Split(<field>,":",2) -> smart
$Split(<field>,":",3) -> fox




Thanks a lot!

Two questions:

1. How to deal with (no) space before and after the delimiter?

2. If a field has a value of "the : smart & fox"

Then,

$Split(<field>,":",1) -> the
$Split(<field>,"&",2) -> fox

But, how can I split "smart"? Do I have to replace "&" with ":" before?
Title: Re: Split the content of a field to multiple virtual fields
Post by: Steven on January 27, 2013, 12:27:15 PM
the function trims all leading and trailing spaces in each split.
the scenario i have in mind with this function is for somewho who has formatted a field a particular way where the field could be split into sub-fields using this function.
I cant imagine a realistic scenario where you would use a mixture of delimiters and be able to reliably parse it into a particlar sub-field consistently, but if someone who would use this function can give an example i will reconsider
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 01:03:01 PM
the function trims all leading and trailing spaces in each split.
the scenario i have in mind with this function is for somewho who has formatted a field a particular way where the field could be split into sub-fields using this function.
I cant imagine a realistic scenario where you would use a mixture of delimiters and be able to reliably parse it into a particlar sub-field consistently, but if someone who would use this function can give an example i will reconsider

Here is an example from my own collection.
The title has a value of "Violin Sonata No. 09 in A, Op. 47 No. 3 'Kreutzer'-mov2a. Andante"
What I liked to do is to split it to "Violin Sonata No. 09,"  "A, Op. 47 No. 3 'Kreutzer,'" and "mov2a. Andante."
So there are two delimiters, "in" and "-."
How do I achieve this without consuming additional number of virtual tags?
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 01:32:20 PM
How about supporting something like this?

$Split(<Title>,("in",2)("-",1))

for "A, Op. 47 No. 3 'Kreutzer,'" part with the example above?
Title: Re: Split the content of a field to multiple virtual fields
Post by: Steven on January 27, 2013, 01:37:00 PM
if you are using a virtual field then in normal circumstances eg. if a display field, then its going to apply to every file - you could of course put in extra conditions in the virtual field definition like testing for a particular genre so the split function is applied to only say your classical music.
So given that, will all your classical music files have that field formatted consistently that way with "in" and "-"?
Title: Re: Split the content of a field to multiple virtual fields
Post by: Steven on January 27, 2013, 01:38:32 PM
How about supporting something like this?

$Split(<Title>,("in",2)("-",1))

for "A, Op. 47 No. 3 'Kreutzer,'" part with the example above?
the function can only output 1 value - i dont see how this suggestion would work
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 01:48:06 PM
will all your classical music files have that field formatted consistently that way with "in" and "-"?

Currently about a half. But that's because their titles were already too long. If this is implemented, I will add additional info to the title field of those tracks. Then it will amount to about 80-90% of my classical music collection. I think an average classical music fan listening to the standard repertoire would have a similar ratio about this if they keep those info in title field though, of course, they might use "," or "." instead of "in."  
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 02:05:45 PM
i've done a Split function
$Split(<field>,"search for text",index)

so a field with a value of: "the : smart : fox"
$Split(<field>,":",1) -> the
$Split(<field>,":",2) -> smart
$Split(<field>,":",3) -> fox

Oh, now I got it. It's already implemented in my MB. When was this included?
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 03:20:04 PM
Never mind. I can afford to use one more virtual tag. I ended up creating "Work," "Key," "Long Work (work+key)," "Movement," and "Short Title" field.

Short Title = $If(<Genre>="Classical",<Work>,<Title>)

It works perfectly. Thanks!
Title: Re: Split the content of a field to multiple virtual fields
Post by: Zak on January 27, 2013, 04:20:50 PM
I can't believe how many classical music composers name their compositions with little to no consideration for people who have to tag them. Someone should send an email to Messrs Beethoven and Chopin et al. and complain!
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 04:34:00 PM
I can't believe how many classical music composers name their compositions with little to no consideration for people who have to tag them. Someone should send an email to Messrs Beethoven and Chopin et al. and complain!

They would, in the first place, abhor the idea that we're listening to the recorded music instead of going to concert halls. Actually some classical musicians refuse to record their performance for the same reason.
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 07:01:27 PM
What if the delimiter is a comma ","? MB doesn't seem to allow it.
Title: Re: Split the content of a field to multiple virtual fields
Post by: Steven on January 27, 2013, 07:24:08 PM
its a bug which i have fixed for the next 2.1 update
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 07:32:29 PM
its a bug which i have fixed for the next 2.1 update

Thanks. It didn't work for $Replace, either.
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 09:14:29 PM
During my test, <Short Title> field sometimes works and sometimes doesn't, with no apparent reason.

Short Title = $If(<Genre>="Classical",<Work>,<Title>)

Sometimes changing its virtual tag number (place) makes it work again.

Is this a bug too?
Title: Re: Split the content of a field to multiple virtual fields
Post by: Steven on January 27, 2013, 09:38:36 PM
this has the parsing fix:
http://musicbee.niblseed.com/V2_1/MusicBee_Exe_Patched.zip

you would need to provide more information about how your fields are configured
Title: Re: Split the content of a field to multiple virtual fields
Post by: redwing on January 27, 2013, 09:49:39 PM
this has the parsing fix:
http://musicbee.niblseed.com/V2_1/MusicBee_Exe_Patched.zip

you would need to provide more information about how your fields are configured

I don't know what you changed, but several problems are gone with the update. So far so good. Thanks!