public static int stringToMidi(String str) {
		if (!str.matches("[a-gA-G][s#b]?-?[0-9]?"))
			return -1;
		int baseNote = noteSeq[(Character.toUpperCase(str.charAt(0)) - 'A')] + 60;
		str = str.substring(1);
		if (str.matches("[s#b]-?[0-9]?")) {
			if (str.charAt(0) == 's' || str.charAt(0) == '#')
				baseNote++;
			else if (str.charAt(0) == 'b')
				baseNote--;
			str = str.replaceAll("[s#b]","");
		}
		if (str.matches("-?[0-9]"))
			baseNote += 12 * (Integer.parseInt(str) - (baseNote>7?4:3));
		return baseNote;
	}