public void generateNotes() throws InvalidChordException {
		// If this is the first chord of the song, treat it differently.
		if (prevBeat == null) {
			generateFirstChord();
			return;
		}
		
		// Until all the rules are followed, continue generating combinations.
		int tries = 0;
		boolean notesFollowAllRules = false;
		while (!notesFollowAllRules) {
			// Generate notes for each voice.
			try {
				for (int voiceIndx = 0; voiceIndx < numVoices; voiceIndx++) {
					generateNote(voiceIndx);
				}
			} catch (InvalidChordException ex) {
				continue;
			}
			
			// Check to make sure this beat follows all the rules.
			notesFollowAllRules = containsAllChordTones(chordTones, chord);
			notesFollowAllRules &= noParallelFifths(prevBeat.getChordTones(),
					chordTones);
			
			// Keep track of the number of attempts. If it goes on for too
			// long, give up.
			tries++;
			if (tries >= 100) {
				System.out.println("Cannot find note combination for this chord");
				throw new InvalidChordException(
						"Cannot find note combination for this chord");
			}
		}
		
		for (int voiceIndx = 0; voiceIndx < numVoices; voiceIndx++) {
			setPlayedNotes(voiceIndx);
			addNonChordTones(voiceIndx);
		}
	}