public float[][] getRealNotes() {
    float[][] novaNotas = new float[this.notesLength][this.maxNote];
    boolean exists;
    float lastSecond;
    int theIndex;
    ArrayList<Number> lastNote;
    ArrayList<ArrayList<Number>> realNotas =
        new ArrayList<
            ArrayList<Number>>(); // Cria um ArrayList com as notas compactadas..usando tecnicas de
    // MapReduce (que sao bem simples)

    for (MIDINote nota : notas) {
      exists = false;
      lastSecond = (float) 0.0;
      theIndex = 0;
      if (realNotas.size() > 0) {
        lastNote = realNotas.get(realNotas.size() - 1);
        for (ArrayList<Number> aNota : realNotas) {
          if (aNota.get(0).floatValue() == nota.getSecond()) {
            exists = true;
            lastNote = aNota;
          } else if (lastSecond < nota.getSecond()
              && aNota.get(0).floatValue() > nota.getSecond()) {
            exists = false;
            break;
          }
          lastSecond = aNota.get(0).floatValue();
          theIndex++;
        }
        if (exists) {
          if (!lastNote.contains(nota.getChord())) {
            lastNote.add(nota.getChord());
          }
        } else {
          lastNote = new ArrayList<Number>();
          lastNote.add(nota.getSecond());
          lastNote.add(nota.getChord());
          realNotas.add(theIndex, lastNote);
        }

      } else {
        lastNote = new ArrayList<Number>();
        lastNote.add(nota.getSecond());
        lastNote.add(nota.getChord());
        realNotas.add(lastNote);
      }
    }

    for (int c = 0; c < realNotas.size(); ++c) {
      ArrayList<Number> notasTrack = realNotas.get(c);
      for (int c2 = 0; c2 < notasTrack.size(); ++c2) {
        // Os outros item nao contem o tempo..portanto, contem o mesmo valor
        novaNotas[c][c2] = (float) notasTrack.get(c2).floatValue();
      }
    }
    return novaNotas;
  }
  private void loadNotes() {
    int program = 0;
    HashMap<Integer, Float> lastTimeNote = new HashMap<Integer, Float>();
    HashMap<Float, Integer> secondsNotes = new HashMap<Float, Integer>();
    this.notas = new ArrayList<MIDINote>();
    for (Track track : sequencia.getTracks()) {
      for (int c = 0; c < track.size(); ++c) {
        MidiEvent event = track.get(c);
        MidiMessage msg = event.getMessage();
        if (msg instanceof ShortMessage) {
          ShortMessage shortmsg = (ShortMessage) msg;
          if (shortmsg.getCommand() == ShortMessage.PROGRAM_CHANGE) {
            program = shortmsg.getData1();
          } else {
            // }else if(program>=25 && program <= 40){
            // else if(program== 30){
            if (shortmsg.getCommand() == ShortMessage.NOTE_ON) {
              MIDINote midiNote = new MIDINote(event, sequencia, tempoProcessor, program);
              // tocador.start();
              int noteChord = midiNote.getChord();
              float noteSecond = midiNote.getSecond();
              if (!lastTimeNote.containsKey(noteChord)) {
                lastTimeNote.put(noteChord, 0.0f);
              }
              if (noteSecond - lastTimeNote.get(noteChord).floatValue() <= this.interval) {
                continue;
              }
              lastTimeNote.put(noteChord, noteSecond);
              // System.out.println("Play chord "+noteChord+" in "+noteSecond+" seconds");
              notas.add(midiNote);
              if (!secondsNotes.containsKey(noteSecond)) {
                secondsNotes.put(noteSecond, 1);
              }
              secondsNotes.put(noteSecond, secondsNotes.get(noteSecond).intValue() + 1);
            }
          }
        }
      }
    }

    // System.out.println("tamanho da pista "+notas.size()+" e track "+maxNote);
    for (float second : secondsNotes.keySet()) {
      int repeated = secondsNotes.get(second).intValue();
      if (repeated > maxNote) {
        this.maxNote = repeated;
      }
    }
    this.notesLength = secondsNotes.size();
    // GameEngine.getInstance().setFramesPerSecond((int)(((tocador.getMicrosecondLength()/1000000)/(notas.size()*1.0))*4000));
    // System.out.println("(int)(("+sequencia.getMicrosecondLength()+"/1000000)/"+notas.size()+"="+(int)((sequencia.getMicrosecondLength()/1000000)/notas.size()))
  }
  // Permite a execucao de uma nota do video
  public void tocar(float seconds, int corda) {
    if (!this.canPlay) {
      return;
    }
    corda = 6 - corda;
    try {
      for (MIDINote nota : this.notas) {

        if (nota.getSecond() == seconds && nota.getChord() == corda) {
          this.recebedor.send(nota.getShortMessage(), -1);
          return;
        }
      }
    } catch (Exception ex) {
      Utilidades.alertar("Erro na execucao do MIDI: " + ex.getMessage());
    }
  }