WHAT IS MIDI CLOCK?
Imagine you have two MIDI devices, one that you want to play prerecorded melody notes and another that can play an internal drum pattern. You want both devices to start and stop playing together, and if the tempo of the melody changes, you want the tempo of the drum pattern to change correctly at the same time.
To do this, you connect a MIDI cable between the MIDI OUT port on your melody device and the MIDI IN port on your drum device. You set your melody device to send MIDI Clock, Start, and Stop messages on its MIDI OUT port. You set your drum device to obey the MIDI Clock, Start, and Stop messages it receives on its MIDI IN port.
In particular, the MIDI Clock message is a one-byte message (hex F8) that, when used, is sent 24 times per quarter note. A MIDI device listening for MIDI Clock messages will adjust its own tempo based on the time between MIDI Clock messages that it sees coming in.
MIDI SEQUENCERS AND MIDI CLOCK
If you are developing a MIDI sequencer, you don't want to record incoming MIDI Clock messages into a MIDI file. But you might eventually consider having advanced options in your sequencer to:
Listen for incoming MIDI Start, Stop, and Clock messages and have your sequencer automatically start, stop, and change tempo, so that it can be remote controlled by another MIDI device.
Generate and send outgoing MIDI Start, Stop, and Clock messages, so that your sequencer can control the playback and tempo of another MIDI device.
If you want to support the really esoteric ability to store arbitrary bytes in a MIDI file (including a MIDI Clock message or anything else) so that they can be sent to the MIDI output port when the file is played, be sure to support the F7 MIDI file message mentioned later, and let users put anything they want to inside of it.
MIDI CABLE MESSAGES AND MIDI FILE MESSAGES
Be aware there are some differences between MIDI messages on a MIDI cable and the messages you encounter in a MIDI file.
For example, on a MIDI cable, the System Real-Time messages can occur between the bytes of other messages. In a MIDI file, they can't.
In fact, on a MIDI cable, the System Common and System Real-Time messages with status bytes of hex F1 to F6 and F8 to FF aren't very useful to store in a MIDI file. When you are expecting a status byte in a MIDI file, some of these bytes are redefined to have a new meaning.
On a MIDI cable, the status byte FF means Reset. But when you are expecting a status byte in a MIDI file, FF is used to mark the beginning of a Meta Event.
On a MIDI cable, the status byte of F7 is used to mark the end of a System Exclusive message. In a MIDI file, the "status byte" of F7 is used to mark the beginning of a message that either contains a partial System Exclusive message that started in a previous message, or contains any other bytes you want to be sent on the MIDI OUT port when the file is played.
WHY WOULD YOU WANT TO STORE A MIDI CLOCK MESSAGE IN A MIDI FILE?
It's usually not useful to store MIDI Clock messages in a MIDI file. However, according to the Standard MIDI File specification, there is a way to store a MIDI Clock message in a MIDI file if you really want to. You have to use the F7 MIDI file message mentioned previously.
Some people who have a Cymatic device want it to play something and also send MIDI Clock messages to some other MIDI device so that the other MIDI device will use the same tempos. Evidently, the Cymatic device doesn't provide an option to generate and send the MIDI Clock messages on its own, but it will send them if they are stored in a MIDI file. I don't know if this works well enough to actually be useful, but it is at least technically possible.
If you want to read the official specifications just for your reference, go to the following page on this website: Specs -> The MIDI 1.0 Specification -> The Complete MIDI 1.0 Detailed Specification
. As described on that page, the main specifications up to 1996 are in the PDF download link "Download the Complete MIDI 1.0 Detailed Specification Document (1996)
Inside that PDF file, the section about the "MIDI 1.0 Detailed Specification" is the main section about MIDI messages that you encounter on MIDI cables. PDF page 62 is where the Clock message is described. Surrounding that, in PDF pages 59 to 64 you can also read about the Start, Stop, Continue, Song Select, and Song Position Pointer messages, with examples of how they relate to Clock messages.
Inside that PDF file, the section "Standard MIDI Files" describes the messages you can encounter in MIDI files. PDF pages 135 and 136 describe the F7 MIDI file message.