Skip to content

Commit

Permalink
lichen-community-systemsGH-5: Tidied up smpte offset and quarter fram…
Browse files Browse the repository at this point in the history
…e handling.
  • Loading branch information
duhrer committed Feb 13, 2023
1 parent 72ba1a1 commit 2f7e77a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@
break;
// Rate and hour most significant bits.
case 7:
quarterFrameObject.rate = (dataBits & 6) >> 1;
quarterFrameObject.rate = (dataBits & 6) >>> 1;
quarterFrameObject.hour = (dataBits & 1) << 4;
break;
default:
Expand Down
5 changes: 3 additions & 2 deletions src/js/smf.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@
// https://www.mobilefish.com/tutorials/midi/midi_quickguide_specification.html
divisionObject.fps = (((~rawDivision) >>> 8) & 127) + 1;

divisionObject.unitsPerFrame = rawDivision & 127;
// Bits 7 through 0 represent the ticks per frame.
divisionObject.ticksPerFrame = rawDivision & 127;
}
// Ticks Per Quarter Note
else {
divisionObject.type = "ticksPerQuarterNote";
// Bits 14 through 0 represent the number of ticks for each quarter note.
divisionObject.resolution = rawDivision & 16383;
divisionObject.resolution = rawDivision & 8191;
}

return divisionObject;
Expand Down
4 changes: 2 additions & 2 deletions tests/js/smf-unit-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
},
// FF 54 05 hr mn se fr ff SMPTE Offset
"SMPTE offset": {
bytes: [0x54, 0x05, 0x0B, 0x13, 0x19, 0x05, 0x32],
object: { type: "smpteOffset", hour: 11, minute: 19, second: 25, frame: 5, fractionalFrame: 50 }
bytes: [0x54, 0x05, 0x6B, 0x13, 0x19, 0x05, 0x32],
object: { type: "smpteOffset", rate: 3, hour: 11, minute: 19, second: 25, frame: 5, fractionalFrame: 50 }
},
// FF 58 04 nn dd cc bb Time Signature
"time signature": {
Expand Down

0 comments on commit 2f7e77a

Please sign in to comment.