def split_tracks(midfile):
    """Break file into different tracks and store them separately

    :param midfile: MidiFile object
    :return: meta messages, instrument messages
    """
    meta_messages = []
    instrument_messages = []
    for i, track in enumerate(midfile.tracks):
        temp_meta_messages = []
        temp_instrument_messages = []
        for msg in track:
            if msg.is_meta:
                temp_meta_messages.append(msg)
            else:
                temp_instrument_messages.append(msg)
        meta_messages.append(temp_meta_messages)
        instrument_messages.append(temp_instrument_messages)
    total_tracks = len(instrument_messages)
    if total_tracks > 4:
        print('Found tracks having more than 4 instruments!\n Removing instruments')
        instrument_messages = instrument_messages[:4]
    return meta_messages, instrument_messages