code: def parse_midi_file(self, file):
          
          try:
              f = open(file, 'r')
          except:
              raise IOError('File not found')
          self.bytes_read = 0
          header = self.parse_midi_file_header(f)
          tracks = header[1]
          result = []
          while tracks > 0:
              events = self.parse_track(f)
              result.append(events)
              tracks -= 1
          f.close()
          return (header, result)
docs: Parse a MIDI file.
  
          Return the header -as a tuple containing respectively the MIDI
          format, the number of tracks and the time division-, the parsed
          track data and the number of bytes read.