private static Note handleNote(
      Note note, List<Note> follwoingNotes, long startTick, long endTick) {
    if (note.getTickPos() < startTick) {
      return note;
    }
    if (note.getTickPos() + note.getDuration() > endTick) {
      return note;
    }

    Note noteToLinkWith = noteToLinkWith(note, follwoingNotes);
    if (noteToLinkWith != null) {
      long newDuration = prolongatedDuration(note, noteToLinkWith);

      Note newNote =
          new Note(
              note.getChannel(),
              note.getPitch(),
              note.getVelocity(),
              note.getTickPos(),
              newDuration);
      slurEndNotes.add(noteToLinkWith);
      slurEndNotes.remove(note);
      return newNote;
    }

    if (slurEndNotes.contains(note)) {
      Note newNote =
          new Note(
              note.getChannel(),
              note.getPitch(),
              (note.getVelocity() * 80) / 100,
              note.getTickPos(),
              (note.getDuration() * 80) / 100);
      slurEndNotes.remove(note);
      return newNote;
    }

    return note;
  }