just completed your code to scan the first 40 bytes of data. It prints the decimal value as well as the hex value using both C-like % formatting and more pythonic format method, which may be more understandable if format specification is in hex.

midi file has been downloaded here and saved in the directory of the script (hence the strange __file__ stuff to compute proper dir when testing)