class_docstr: Reader class for 'mid.scp'.
  
  Examples:
      key1 /some/path/a.mid
      key2 /some/path/b.mid
      key3 /some/path/c.mid
      key4 /some/path/d.mid
      ...
  
      >>> reader = XMLScpReader('mid.scp')
      >>> tempo, note_list = reader['key1']
class_docstr_tok: ["Reader","class","for","'mid.scp","'",".","Examples",":","key1","\/some\/path\/a.mid","key2","\/some\/path\/b.mid","key3","\/some\/path\/c.mid","key4","\/some\/path\/d.mid","...",">",">",">","reader","=","XMLScpReader","(","'mid.scp","'",")",">",">",">","tempo",",","note_list","=","reader","[","'key1","'","]"]
code: def __getitem__(self, key):
      midi_obj = miditoolkit.midi.parser.MidiFile(self.data[key])
      # load tempo
      tempos = midi_obj.tempo_changes
      tempos.sort(key=lambda x: (x.time, x.tempo))
      assert len(tempos) == 1
      tempo = int(tempos[0].tempo + 0.5)
      # load pitch time sequence
      tick_to_time = midi_obj.get_tick_to_time_mapping()
      notes = midi_obj.instruments[0].notes
      notes.sort(key=lambda x: (x.start, x.pitch))
      notes_list = []
      pre_et = 0
      for note in notes:
          st = tick_to_time[note.start]
          et = tick_to_time[note.end]
          # NOTE(Yuning): MIDIs don't have explicit rest notes.
          # Explicit rest notes might be needed for stage 1 in svs.
          if st != pre_et and self.add_rest:
              notes_list.append(NOTE("P", 0, pre_et, st))
          notes_list.append(NOTE("*", note.pitch, st, et))
          pre_et = et
      return tempo, notes_list
  
imports: import collections.abc
  import json
  from pathlib import Path
  from typing import Union
  import numpy
  from typeguard import check_argument_types
  from espnet2.fileio.read_text import read_2columns_text
label_desc: Use image node_id 2 for calling the MIDReader obj's underlying member method code with example usage: obj.__getitem__(key) and returns: tempo,  notes_list