INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression question related to all the recent classical music talk  (Read 816 times)

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354

After reading all the posts so far about better support for classical music and Wer's tagging workflow thread, I decided to maybe, finally, tackle my inconsistent [Name] fields, as per the discussion a couple of months ago here

https://yabb.jriver.com/interact/index.php/topic,128127.msg888912.html#msg888912

where I was interested in a view scheme that would help me weed out duplicate recordings (old rips vs. newer remasters, for example) of classical compositions.

I don't need to build [Composition] from [Name] as per the workflow thread mentioned above, since I tag from AMG using MCUtils, and [Composition], [Composer], and performers are about 99% consistent, with only the rare exception, but I would like to have a more foolproof (and quicker) way to find duplicate performances of compositions, plus just have [Name] be consistent.

I've filled [Name] using the basic "composition: movement" scheme already talked about in the two recent classical music threads. Therefore, because composition is consistent, everything to the left of the colon should be fine (and works without movements just get the composition as [Name]). Movement is another matter entirely because I wasn't and haven't been careful with it: basically, I've just taken what AMG has given me, which can vary a bit. For example, if there's an album that begins with Beethoven's Symphony No. 5, track 1 might come back from AMG as "1. Allegro con brio," "I. Allegro con brio," "Allegro con brio," or even something like "Movement I: Allegro con brio" or "No. 1: Allegro con brio."

Right now I'm trying to parse out the movement number on [Name]. For movements that were tagged with an arabic numeral plus a period (e.g., "1." or "4.") I created my first working Regex (!) for a quick fill-in of [Movement Number]:

Code: [Select]
=If(Regex([Name],/#:\s(\d)#/,1,0),[R1])
For Roman Numeraled movements, I just did a series of Find and Replaces. And for ones with "No.," I created another working Regex to fill in [Movement Number]:

Quote
=if(regex([name],/#:\sNo.\s(\d)#/,1,0),[R1])

And so on. Now I'm stumped on ones that have no number or regular text like "No." or "Movement," like simply "Allegro con brio." It would seem that I'd need to do something like an expand on [Composition] for a given album and performance and then somehow count the number of tracks of that composition in order (guided by the order of [Track #], if not the track numbers themselves), but I can't figure out how to do it, or if it's even possible without [Composition] being a relational field, if that's the right term. I did look at GroupCountQuery but couldn't figure out how to get a counter to work with it. Maybe some of the changes Matt is making at Wer's behest will help here? Or is there some other way I'm missing?

Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression question related to all the recent classical music talk
« Reply #1 on: March 12, 2021, 10:45:33 pm »

For Roman Numeraled movements, I just did a series of Find and Replaces.

Interesting you mentioned Roman Numerals. I wrote a Roman Numeral converter in the expression language a while back, but necessarily it had some limitations. So a better version is actually one of the things Matt coded in for me. You should be able to use it soon.

Now I'm stumped on ones that have no number or regular text like "No." or "Movement," like simply "Allegro con brio." It would seem that I'd need to do something like an expand on [Composition] for a given album and performance and then somehow count the number of tracks of that composition in order (guided by the order of [Track #], if not the track numbers themselves), but I can't figure out how to do it, or if it's even possible without [Composition] being a relational field, if that's the right term. I did look at GroupCountQuery but couldn't figure out how to get a counter to work with it. Maybe some of the changes Matt is making at Wer's behest will help here? Or is there some other way I'm missing?

I'm not quite sure what you are trying to do here. Are you trying to get the count of the number of tracks in a composition?  That can be done with GroupCountQuery.  Or are you trying to infer the movement number just from the presence of other tracks? (In other words, this composition has 4 tracks, so they should get movement numbers 1, 2, 3, 4 in order of ascending track #.)

The second one is trickier, and the approach depends on whether you want to do 10 files or 10,000.
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression question related to all the recent classical music talk
« Reply #2 on: March 12, 2021, 11:37:58 pm »

Good to hear about the Roman Numeral converter!

Regarding your question, this is what I'm trying to do:
Quote
Or are you trying to infer the movement number just from the presence of other tracks? (In other words, this composition has 4 tracks, so they should get movement numbers 1, 2, 3, 4 in order of ascending track #.)

I want to do over 50,000 files but realize that's not realistic.

Logged

EnglishTiger

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 966
Re: Expression question related to all the recent classical music talk
« Reply #3 on: March 13, 2021, 12:01:09 am »

Are you trying to get the count of the number of tracks in a composition?  That can be done with GroupCountQuery.  Or are you trying to infer the movement number just from the presence of other tracks? (In other words, this composition has 4 tracks, so they should get movement numbers 1, 2, 3, 4 in order of ascending track #.)

Wer - could using GroupCountQuery, to get the number of tracks in a Composition, be used to populate a Substitute "Movement Count" tag/field?
Logged
Win NUC - VENOEN 11Th NUC Mini PC Core i7 1165G7,Dual HDMI 2.0+Mini DP,Windows 11 Mini Desktop Computer,Thunderbolt 4.0,1 Lan, USB-C,Wifi,Bluetooth 5.0,32GB RAM Toshiba MQ04ABF100 ‎500Gb 5400 RPM ‎eSATA HD, Gigabyte GP-GSM2NE3512GNTD 1Tb NVMe SSD, Samsung 870 QVO 8 TB SATA 2.5 Inch SSD (MZ-77Q8T0) in Sabrent Ultra Slim USB 3.0 to 2.5-Inch SATA External Aluminium Hard Drive Enclosure (EC-UK30)

Apple 2020 Mac mini M1 Chip (8GB RAM, 512GB SSD)
Sabrent Thunderbolt 3 to Dual NVMe M.2 SSD Tool-Free Enclosure with Sabrent 2TB Rocket NVMe PCIe M.2 2280 High Performance SSD + Crucial P3 Plus 4TB M.2 PCIe

ET Skins & TrackInfo Plugins - https://englishtiger.uk/index.html

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression question related to all the recent classical music talk
« Reply #4 on: March 13, 2021, 12:10:28 am »

I don't understand your question, ET. Naturally an expression can be used to populate any field, one way or another. But I don't know what you intend.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression question related to all the recent classical music talk
« Reply #5 on: March 13, 2021, 12:38:09 am »

I want to do over 50,000 files but realize that's not realistic.

Yeah well that is unfortunate.  I deal with non-conformant files when I rip or import them, so it's in small batches. I never allowed myself to amass such a large backlog. 50,000...  :)  I'm not sure you'll escape without some suffering.

A way could be written using global variables. It would be of moderate complexity, and then you would need some tricks to get the resultant values into a field. But it could be done. Then you could process them through a smartlist in batches. Perhaps all at once, but I myself would do it in batches just so things don't get out of control.

But I have never taken the time to write the thing, because I haven't needed it. A man doesn't need to design and build a backhoe when when a shovel will suffice.  ;D  Only when you suddenly need a thousand holes do you have the need. Seems like you have the need. Are you up to writing it?

There's another way I can think of. You can leverage the "Fill Track Numbers from list order" tool. This would be considerably facilitated if you have populated a [Composition Order] field or something like it. Do you have that?

I'm not sure if I've ever talked about [Composition Order].  It's a field I create, that's basically the equivalent of [Track #] but for Compositions. The problem is MC doesn't know any way to properly order/sort Compositions (as in the order they appear on disc). It could sort them alphabetically, which would often be wrong, or by other tags, which would also be wrong. It can't sort by Track #, because there is no single Track # for a Composition: each of the four tracks in a comp has a different track number, so that's nonsense.  So I give each Composition on an album a number in [Composition Order].  So each track in the first Composition has [Composition Order]=1, each track in the 2nd comp has [Composition Order]=2 and so on. I use it to sort Compositions. If you have that it will help.

The idea would be you copy that number into [Disc #].  Then you can tell the "Fill Track Numbers from list order" to populate the Episode tag, starting at 1 and restarting every time the disc # field changes.  Shazaam, the Episode tag suddenly holds your Movement Number.  A little expression kung-fu and you move it where you need it.  See what I mean?

It certainly would be nice if that tool were enhanced to be able to cycle on Composition, and populate the Movement Number field. Perhaps if enough people send gifts to Matt he will hearken. I've proposed this as a feature here. You'd better go there and plead. Matt can save you!  ;)

Those are the options that I can think of off the top of my head.

Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2389
Re: Expression question related to all the recent classical music talk
« Reply #6 on: March 13, 2021, 04:55:57 am »

Wer's idea for the numbering tool would be nice for this.

If you can sort the files by the order you want in MC, you could just copy to Excel, apply a simple formula to number them, then copy back to MC.
if col A is the Composition name, you can simply put this in column B:
=IF(A2=A1,B1+1,1)

You can adjust the formula to restart at 1 on a different condition, using more fields if needed.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression question related to all the recent classical music talk
« Reply #7 on: March 13, 2021, 05:27:15 am »

Ha!  Actually I had just come back to add that you could also do something in Excel and I saw Zybex beat me to it.
Logged

EnglishTiger

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 966
Re: Expression question related to all the recent classical music talk
« Reply #8 on: March 13, 2021, 05:34:34 am »

I've added a new movement related tag/field "Total Movements" to replace the existing "Movement Count" one and managed to auto populate it using this expression

Code: [Select]
If(IsEqual([Composition],[Name]),,GroupCountQuery(Composition; Album, Movement Name))
"Album" is there to restrict the search to the current album, some of my compositions appear on  more than one album, and "Movement Name" is there to ensure GroupCountQuery is counting a set of unique/different values.

I also have a tag/field called "Composer's Catalogue #" and I am now able to auto populate it using this expression

Code: [Select]
If(IsEqual([Composition],[Name]),,ListItem([Composition],1,;))
To extract the part of the "Composition" tag after the ;

 ;D
Logged
Win NUC - VENOEN 11Th NUC Mini PC Core i7 1165G7,Dual HDMI 2.0+Mini DP,Windows 11 Mini Desktop Computer,Thunderbolt 4.0,1 Lan, USB-C,Wifi,Bluetooth 5.0,32GB RAM Toshiba MQ04ABF100 ‎500Gb 5400 RPM ‎eSATA HD, Gigabyte GP-GSM2NE3512GNTD 1Tb NVMe SSD, Samsung 870 QVO 8 TB SATA 2.5 Inch SSD (MZ-77Q8T0) in Sabrent Ultra Slim USB 3.0 to 2.5-Inch SATA External Aluminium Hard Drive Enclosure (EC-UK30)

Apple 2020 Mac mini M1 Chip (8GB RAM, 512GB SSD)
Sabrent Thunderbolt 3 to Dual NVMe M.2 SSD Tool-Free Enclosure with Sabrent 2TB Rocket NVMe PCIe M.2 2280 High Performance SSD + Crucial P3 Plus 4TB M.2 PCIe

ET Skins & TrackInfo Plugins - https://englishtiger.uk/index.html

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2389
Re: Expression question related to all the recent classical music talk
« Reply #9 on: March 13, 2021, 05:42:26 am »

Just a caveat regarding formulas using Group query functions - they're SLOW. They're supposed to recalculate only once per minute, but even so, having them in an Expression field is bound to cause slowness and speed bumps.

It would be nice to have a way to copy the value of an expression field to another field (as text/number, not expression), sort of like Excel's "paste as values". This way we could use these complex expressions to generate the needed values, and then keep the values and discard the expressions.

I suppose we need to copy into excel and then pasta back into MC to do that.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression question related to all the recent classical music talk
« Reply #10 on: March 13, 2021, 06:01:34 am »

It would be nice to have a way to copy the value of an expression field to another field (as text/number, not expression), sort of like Excel's "paste as values". This way we could use these complex expressions to generate the needed values, and then keep the values and discard the expressions.

I suppose we need to copy into excel and then pasta back into MC to do that.

When you said "expression field" did you actually mean "expression column"?

Ah, but you can do this in MC, Grasshopper.  ;)

Show the field you want to paste the value into as a column, F2 to edit, and paste in the expression. The expression will evaluate, and the field will get the value, not the expression.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2389
Re: Expression question related to all the recent classical music talk
« Reply #11 on: March 13, 2021, 06:24:54 am »

And that, ladies and gents, was a "temporary mental lapse or failure to reason correctly." (according to Oxford dictionary...)  ;D
Thanks Wer. I was thinking of expression columns.
 
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression question related to all the recent classical music talk
« Reply #12 on: March 13, 2021, 09:39:26 am »

Thanks Zybex and Wer for the suggestions.

The Excel route seems best, as I don't really have a consistent [Composition Order]-type field. There is a similar thing in MCUtils called [AMG Work Part Index] which parses composition movement numbers out of another field, [AMG Work Parts] derived from AMG. I just found a little problem in its automatic filling, however, and that makes these unreliable (if movements 2 and 4 are the same name, "Allegro," say,  the [AMG Work Part Index] fills in a 2 for both the second and fourth movements). And not all compositions on AMG have movement parts listed anyway, especially when you get into more obscure composers/works.

Anyway, let me try the Excel thing and report back if I have questions and/or get it working.

Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression question related to all the recent classical music talk
« Reply #13 on: March 13, 2021, 02:46:47 pm »

OK Zybex, I've barely used Excel before and am stuck (and Googling doesn't seem to be getting me anywhere).

As a test, I copied from MC a playlist with 1 composition on it (called [AMG Work Name]) as column A (see attached image). That's right, yes?

I click column B and put the expression in the blank near the top, right? Next to the "Insert Function" button? I did modify what you gave me to reflect the rows and columns I have in Excel:

Code: [Select]
=IF(A3=A2,B2+1,1)
After I hit enter in Excel, nothing seems to happen. What am I doing wrong?

Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2389
Re: Expression question related to all the recent classical music talk
« Reply #14 on: March 13, 2021, 02:53:12 pm »

- Delete B1
- Set B2 to: =IF(A2=A1,B1+1,1)
- Double-click the bottom-right corner of the B2 cell - Excel will copy the formula all the way down (in your case, to B3 and B4)

That's it, it should show up some numbers in B column. You will then have to select all cells with numbers (mouse drag), CTRL, and CTRL+SHIFT+V into MC. Make sure you do an MC backup before this, you WILL mess it up at first :)

Ideally you should test this with more than 3 rows to check if the numbering resets to 1 when needed.
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression question related to all the recent classical music talk
« Reply #15 on: March 13, 2021, 03:10:26 pm »

Got it! Thanks so much, Zybex!
Logged
Pages: [1]   Go Up