# Actions to modify BPM: Double, Half, Round to Integer

**URL:** https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295
**Category:** Support
**Created:** [October 6, 2008, 2:16am UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295 "2008-10-06T02:16:08Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Moonbase](https://community.mp3tag.de/user_avatar/community.mp3tag.de/moonbase/32/207_2.png) [@Moonbase](https://community.mp3tag.de/u/Moonbase)
#### Post date: [October 6, 2008, 2:16am UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/1 "2008-10-06T02:16:08Z")

</div>

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:

1. **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.
2. **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.
3. **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.)

All 3 action groups are tested and found robust to handle real-life data. They will graciously handle input formats like **xxx** , **xxx.xx** , **.xx** , **xxx.** , **xxx.x** , **xxx.xxx…**. All are based on the same code fragments (actions) but separated into 2 or 3 single actions per group so that you can easily make your own changes (i.e., store BPM as integer BPM\*100, a format that _some_ rare software uses). If you use any of these on a file that _doesn’t_ (yet) contain a BPM tag, one will be created with BPM set to zero (0 or 0.00).

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 BPM_100 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 BPM_100 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.)

---

_[View the full topic](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295)._
