ipatix/csmidi

How do I know how much tick per second?

Closed this issue · 1 comments

How do I know how much tick per second?

After loading a MIDI file you can read the field MidiFile.timeDivision. This tells you the tick count per beat (usually 1/4 note). The actual speed is determined by the song itself using a Meta event (MetaType.TempoSetting) which contains the microseconds per beat in big endian format (3 bytes).
Because I didn't design csmidi particulary well, reading/writing the meta event data is not quite straight forward. Use MetaMidiEvent.getEventData(), omit the first two bytes, and the leftover 3 bytes are your µs/beat.

From there you can use basic math to calculate the ticks per second.