public ArrayList<Integer> parseMidi(File midi) throws Exception {
		Sequence sequence = MidiSystem.getSequence(midi);
		ArrayList<Integer> notes = new ArrayList<Integer>();
		long noteOffTime = Long.MAX_VALUE;
		boolean firstNote = true;
		for (Track track :  sequence.getTracks()) {
			for (int i=0; i < track.size(); i++) { 
				MidiEvent event = track.get(i);
				MidiMessage message = event.getMessage();
				if (message instanceof ShortMessage) {
					ShortMessage sm = (ShortMessage) message;
					if (sm.getCommand() == NOTE_ON && sm.getData2()>0) { // Check so it is a hit and that it has velocity
						if(!firstNote && noteOffTime+2 < event.getTick())
						{
							/*
							 * Paus lengths:
							 * whole-note: 			1921 ticks
							 * half-note: 			961 ticks
							 * quarter-note: 		481 ticks
							 * eighth-note: 		241 ticks
							 * sixteenth-note: 		121 ticks
							 * thirty-second-note: 	61 ticks
							 * sixty-fourth-note: 	31 ticks 
							 */
							notes.add((int)(noteOffTime-event.getTick()));
							DebugMessage.msg("Paus: "+(event.getTick()-noteOffTime),debug);
						}
						//System.out.println("Note added");
						notes.add(sm.getData1()); // Adds the note to the list
						if(firstNote)
							firstNote = false;
					} 
					//System.out.println(sm.getCommand());
					if (sm.getData2()==0)
					{
						noteOffTime = event.getTick();
						
					}
				} 
			}         
		}
		return notes;
	}