There seems to be some need for reliably changing the BPM tag (TBPM, Beats Per Minute) and I've seen some unreliable code out there, so I came up with some Action Groups to do the following:
- Double the BPM value. In case your BPM Analyzer has detected only half the rate. Knowingly creates the much-used (but technically illegal) xxx.xx format.
- Reduce the BPM value by one half. In case your BPM Analyzer has detected double the rate. Knowingly creates the much-used (but technically illegal) xxx.xx format.
- Round fractioned BPM to Integer value. To put BPM back to an integer value, if your mixer application doesn’t support fractioned BPM values. Fractional values will be rounded to the next integer. (Makes an ID3v2 standards conformant xxx format.)
Now here’s the code. I assume that you are comfortable modifying the column view and setting up actions and action groups. If not, please study the help/manual.
I strongly recommend setting up an extra column containing the BPM field so that you can actually see and follow the changes!
Action Group »BPM Double«
Format value:
Field: BPM
Format string: $if($grtr($strchr(%BPM%,'.'),0),$add($mul($left(%BPM%,$sub($strchr(%BPM%,'.'),1)),100),$left($mid(%BPM%,$add($strchr(%BPM%,'.'),1),2)00,2)),$mul(%BPM%,100))
Format value:
Field: BPM
Format string: $mul(%BPM%,2)
Format value:
Field: BPM
Format string: $ifgreater(%BPM%,0,$left(%BPM%,$sub($len(%BPM%),2)).$right(%BPM%,2),0.00)
Action Group »BPM Half«
Format value:
Field: BPM
Format string: $if($grtr($strchr(%BPM%,'.'),0),$add($mul($left(%BPM%,$sub($strchr(%BPM%,'.'),1)),100),$left($mid(%BPM%,$add($strchr(%BPM%,'.'),1),2)00,2)),$mul(%BPM%,100))
Format value:
Field: BPM
Format string: $div(%BPM%,2)
Format value:
Field: BPM
Format string: $ifgreater(%BPM%,0,$left(%BPM%,$sub($len(%BPM%),2)).$right(%BPM%,2),0.00)
Action Group »BPM Round to Integer«
Format value:
Field: BPM
Format string: $if($grtr($strchr(%BPM%,'.'),0),$add($mul($left(%BPM%,$sub($strchr(%BPM%,'.'),1)),100),$left($mid(%BPM%,$add($strchr(%BPM%,'.'),1),2)00,2)),$mul(%BPM%,100))
Format value:
Field: BPM
Format string: $div($add(%BPM%,50),100)
As you can see, the first action is always the same: It reads an existing BPM value and stores it back as an integer BPM100 value (i.e., 123.45 becomes 12345). The second action does something to the BPM value, i.e. multiplying it by 2, dividing it by 2, or rounding it to the nearest full integer. The third action (if used) converts the integer BPM100 result back into the xxx.xx format, which is (strictly spoken) »illegal« in ID3v2 but nevertheless used in this form by many applications. (And besides, as any good DJ will tell you, they need about 0.05 BPM precision anyway.) So we knowingly violate the specs here (and hope they come up with a redefinition at some point in time.
If you want to strictly adhere to the spec, you can always use the »BPM Round to Integer« action group after doing your other changes.
Voilà! BPMs made easy!
Hope you can use and enjoy these.
A word of caution for Mixmeister BPM Analyzer users:
Mixmeister BPM Analyzer always stores the BPM as an ID3v2.3 UTF-16 TBPM tag and MP3Tag will probably not show you that! Also, there is a known issue with Mixmeister corrupting cover images if ID3v2.4 is used. So if you are using ID3v2.3 and ISO-8859-1 encoding or ID3v2.4 and UTF-8 encoding, you will have some problems! Seen technically, it is perfectly legal to mix a zillion encodings in one file, but from a practical standpoint, it’s pure nonsense—you’ll end up with a lot of hard to diagnose problems.
If you don’t already have the TBPM tag in your file, Mixmeister will add one PLUS write back all your tags as ID3v2.3 with UTF-16 encoding. All without asking or any configuration options.
So my advice is: You can use Mixmeister BPM Analyzer (it’s one of the most accurate BPM detectors around) but you should have set up your MP3Tag to save the kind of tags you need and in any case re-save your tags with MP3Tag after using Mixmeister! (Simply select one, several or all files and press Ctrl-S for Save, or use the diskette symbol in the toolbar.)