# 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:** 9
**Page:** 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.)

---

<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:43am UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/2 "2008-10-06T02:43:33Z")

</div>

Oh, well. I remember that someone wanted to round their BPM values to 10's values, i.e. only »groups« like **80, 90, 100, 110, …**

Just to make things complete (and as an example how you can modify these), here’s the code:

**Action Group »BPM Round to Tens«**

```
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($sub($add(%BPM%,500),$mod($add(%BPM%,500),1000)),100)

```

Have fun!

---

<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, 11:03am UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/3 "2008-10-06T11:03:29Z")

</div>

Someone has been asking for »How to make fractional (xxx.xx) BPM values from whole numbers?«. Easy: Take above »BPM Double« or »BPM Half« example and just _leave out the middle action_, i.e. leave out the calculation part:

**Action Group »BPM convert to fractional (xxx.xx)«**

```
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: $ifgreater(%BPM%,0,$left(%BPM%,$sub($len(%BPM%),2)).$right(%BPM%,2),0.00)

```

This will convert your BPM from almost any format (xxx, xxx.x, xxx.xxx) into **xxx.xx** (fractional, 2 decimal digits of precision).

---

<div class="post-metadata">

### Author: ![erdubya](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/e19adc/32.png) [@erdubya](https://community.mp3tag.de/u/erdubya)
#### Post date: [October 20, 2008, 2:56am UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/4 "2008-10-20T02:56:36Z")

</div>

Thanks for the actions,

I'm experimenting with them now but I have one question.

Is there a way to include if logic (not sure about the syntax) to do something like this in the second action?

IF BPM \> 100  
Then Half it.

Otherwise do nothing.

Since I know most (if not all) my songs are say less than 100, I can select all of them and have mp3 tag do all the work for me, instead of me having to manually select the obvious erroneous (double) bpm'd songs.

Thanks!

---

<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 20, 2008, 9:50am UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/5 "2008-10-20T09:50:41Z")

</div>

> [@erdubya](#):
>
> […] IF BPM \> 100  
> Then Half it. Otherwise do nothing. […]

Sure thing, with MP3Tag you can do almost anything you want 🙂

Make a copy of the Action Group »BPM Half« above, maybe name it »BPM Half if over 100«, then change the _second_ action in the group as follows:

```
$ifgreater(%BPM%,10000,$div(%BPM%,2),%BPM%)

```

(We need to test for _\> 10000_ here since we have converted BPM to BPM\*100 as an integer value in the action before.)

_A word of caution:_ I recommend being _very careful_ with »generalized« changes like that—you might change a lot of songs whose BPM really _are_ above 100.

---

<div class="post-metadata">

### Author: ![vital](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vital](https://community.mp3tag.de/u/vital)
#### Post date: [July 28, 2009, 6:21pm UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/6 "2009-07-28T18:21:38Z")

</div>

how about if the decimal is \<.05 then truncate or if \>.95, then round up?

---

<div class="post-metadata">

### Author: ![crispinr](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/b4bc9f/32.png) [@crispinr](https://community.mp3tag.de/u/crispinr)
#### Post date: [September 14, 2013, 3:48am UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/7 "2013-09-14T03:48:57Z")

</div>

Hi Moonbase - Thanks for these actions - really useful!

I have one issue, most tracks have correct BPM, but I have now a selection of tracks where the BPM appears to have been multiplied by a factor of 10, eg 92.25 is now 922.50

Have I done something wrong (I've copied your code without changes) or is there another action I can apply to the divide BPM by a factor of 10?

Thanks for your help!

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [September 15, 2013, 5:15am UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/8 "2013-09-15T05:15:36Z")

</div>

> [@crispinr](#):
>
> ...eg 92.25 is now 922.50
> 
> Have I done something wrong..

It is ery hard to tell from the distance what has gone wrong.  
I think that iTunes ignores bpms with decimals (at least that was it like some versions ago and I never checked again). So it would be just as good to remove these fragments altogether.

To move the decimal point left use the following action:  
Replace with regular expression for bpm  
Search string: (\d).(\d)  
Repace string: .$1$2

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:21pm UTC](https://community.mp3tag.de/t/actions-to-modify-bpm-double-half-round-to-integer/7295/9 "2026-02-09T12:21:08Z")

</div>


