Skip to content

Commit

Permalink
Fix interpretation of negative effective BPM, #55
Browse files Browse the repository at this point in the history
  • Loading branch information
brunchboy committed Oct 7, 2023
1 parent a2ed879 commit 604ea70
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/org/deepsymmetry/beatlink/PrecisePosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ public PrecisePosition(DatagramPacket packet) {
super(packet, "Precise position", 0x3c);
trackLength = (int)Util.bytesToNumber(packetBytes, 0x24, 4);
playbackPosition = (int)Util.bytesToNumber(packetBytes, 0x28, 4);
pitch = (int)Util.percentageToPitch(Util.bytesToNumber(packetBytes, 0x2c, 4) / 100.0);
long rawPitch = Util.bytesToNumber(packetBytes, 0x2c, 4);
if (rawPitch > 0x80000000L) { // This is a negative effective tempo
rawPitch -= 0x100000000L;
}
pitch = (int)Util.percentageToPitch(rawPitch / 100.0);
bpm = (int)Util.bytesToNumber(packetBytes, 0x38, 4) * 10;
}

Expand Down

0 comments on commit 604ea70

Please sign in to comment.