Skip to content

Commit

Permalink
fix BPM rounding error (monome#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
scanner-darkly authored Feb 2, 2023
1 parent 9f8c9e9 commit abf9784
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- **FIX**: reset M timer when changing metro rate
- **NEW**: new Drum Ops: `DR.T`, `DR.V`, `DR.P`
- **NEW**: [I2C2MIDI](https://github.com/attowatt/i2c2midi) ops
- **FIX**: fix BPM rounding error

## v4.0.0

Expand Down
1 change: 1 addition & 0 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- **FIX**: reset M timer when changing metro rate
- **NEW**: drum ops: `DR.P`, `DR.V`, `DR.TR`
- **NEW**: [I2C2MIDI](https://github.com/attowatt/i2c2midi) ops
- **FIX**: fix BPM rounding error

## v4.0.0

Expand Down
3 changes: 2 additions & 1 deletion src/ops/maths.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,8 @@ static void op_BPM_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
uint32_t ret;
if (a < 2) a = 2;
if (a > 1000) a = 1000;
ret = ((((uint32_t)(1 << 31)) / ((a << 20) / 60)) * 1000) >> 11;
ret = ((((uint32_t)(1 << 31)) / ((a << 20) / 60)) * 1000) >> 10;
ret = ret / 2 + (ret & 1); // rounding
cs_push(cs, (int16_t)ret);
}

Expand Down

0 comments on commit abf9784

Please sign in to comment.