-
Notifications
You must be signed in to change notification settings - Fork 237
midi: minor fixups #1023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
midi: minor fixups #1023
Conversation
format/midi/constants.go
Outdated
-24: 24, | ||
-25: 25, | ||
-29: 29, | ||
-30: 30, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh what is this weird mapping? :) is stored as 2's compliment but the abs value is always used? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, welcome to the wonderful world of MIDI :-).
However, fair point and I've remapped them to strings for clarity because 29 is not 29 - it's actually "29.97 FPS and drop the occasional frame to keep things in sync". And also discovered a bug in the SMPTE offset event decoding while I was at it, so good call!
FYA: here's the relevant bit of the spec:
If bit 15 of is a one, delta-times in a file correspond to subdivisions of a second, in
a way consistent with SMPTE and MIDI time code. Bits 14 thru 8 contain one of the four
values -24, -25, -29, or -30, corresponding to the four standard SMPTE and MIDI time code
formats (-29 corresponds to 30 drop frame), and represents the number of frames per second.
These negative numbers are stored in two's complement form. The second byte (stored
positive) is the resolution within a frame: typical values may be 4 (MIDI time code resolution),
8, 10, 80 (bit resolution), or 100. This system allows exact specification of time-code-based
tracks, but also allows millisecond-based tracks by specifying 25 frames/sec and a resolution of
40 units per frame. If the events in a file are stored with bit resolution of thirty-frame time
code, the division word would be E250 hex.
and:
The new counting system counts from 0 to 29 for most seconds, but skips frame 0 and frame 1 for some
seconds, jumping directly from frame 29 of the previous second to frame 2 of the next second. This counting
system is called “drop frame.”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh 29.97 i guess from the us electric grid? same thing shows up in other digital media formats :) i guess you could use sym float if you think ppl would like to use the value in queries etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's from film to NTSC (TV) conversion - there's a whole long writeup here if you're interested.
re. sym float. I thought about it but the rate is actually 29.97002997 and drop a frame so however you code it you're going to end up writing a switch statement. Clarity seemed the better way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! looks good, just had some minor comments and questions
Looks good to me! merge? |
re. merge. I don't have anything else to add so I'm good to merge if you're happy :-) |
Thanks! |
<smile> always a pleasure .. give my regards to the cats! |
Awwwww .. they're beautiful :-) :-) |
Hi,
This pull request implements some small cleanups for the midi plugin: