I've tagged all my MP3 files using a free tool called MixMeister.
It has written the info into the TBPM tag to 2 decimal places. This is not quite in line with the ID3 standard (which states that the TBPM tag should contain an integer) and that is causing problems with other software.
I'd like to run an Action to conver all the TBPM values to integer.
Ideally I'd like to round the values - so, for example, that 140.25 would become 140, and 140.81 would become 141 - although guess that's quite a tall order!
So, alternatively, I'd just like to truncate the values by removing the decimal places and two following numbers, so 140.25 or 140.81 would just become 140.
I haven't quite worked out how to write custom actions, so would be very grateful if someone could suggest the correct syntax for me!
Create an action group 'Round BPM to integer'.
Create following actions:
Action #1: Action type:Format value Field:BPM Formatstring:$if($neql(%BPM%,$replace(%BPM%,'.',)),$replace(%BPM%,'.',),%BPM%'00') Formatstring (alternative):$if($eql($strchr(%BPM%,'.'),0),%BPM%'00',$replace(%BPM%,'.',))
Action #2: Action type:Format value Field:BPM Formatstring:$ifgreater($mod(%BPM%,100),49,$add($div(%BPM%,100),1),$div(%BPM%,100))
Testcases:
If BPM contains a decimal point, then it must have 2 decimals.
123 ==> 123
123.49 ==> 123
123.50 ==> 124
123.00 ==> 123
123.99 ==> 124
DD.20070122.1807
Edit. Changed erroneous 44 to 49.
DD.20120717.1513.CEST
My example should work with v2.37a, there is no new thing in the expressions.
Maybe there is another problem on your machine.
Try the latest Mp3tag development build and you will be fine.
There was no regular expression applied. The delivered code is simply all day Mp3tag programming script language.
When Mp3Tag is on the screen press the standard help key F1, and you will get the Mp3tag help pages. Even there are not all features well documented, it can help you to do your first steps with Mp3tag.
You're right, there may be a problem on my machine. I'll keep looking!
In the meanwhile, I've started messing about with some action scripts, and have come up with something that kinda works (although it assumes that there will always be 2 decimal places in every BPM tag so I'll need to check that is definitely true).
I have a slightly new version, which allows different number formats for input BPM value, with or without decimal point, up to two decimal places.
Old BPM (Mixmeister) value will be saved into a new field BPM_MIXMEISTER for sure.
By your prolific posting, I'm guessing/hoping you enjoyed my BPM challenge
I've just re-read your suggestions while referring to the scripting reference, and have realised that you are not rounding values above .44 upwards (which is what I initially thought before I understood how the functions worked ) but are rather, as you say, dividing and evaluating the remainder.