// Obtiene una lista de notas candidatas que pertenezcan al grado de la tonalidad y esté en la // lista de disponibles public static List<Nota> obtenerNotas(String tonalidad, Integer grado, Nota[] notasDisponibles) { List<Nota> result = new ArrayList<Nota>(); List<String> acorde = new ArrayList<String>(); // 1. Obtener las notas del acorde sobre el grado indicado // añadir la fundamental int idx = NOTAS.indexOf(tonalidad.substring(0, 1)); idx += grado - 1; if (idx >= NOTAS.size()) idx -= NOTAS.size(); acorde.add(NOTAS.get(idx)); // añadir la tercera idx += 2; if (idx >= NOTAS.size()) idx -= NOTAS.size(); acorde.add(NOTAS.get(idx)); // añadir la quinta idx += 2; if (idx >= NOTAS.size()) idx -= NOTAS.size(); acorde.add(NOTAS.get(idx)); // 2. Añadir al resultado las notas disponibles que pertenezcan al acorde for (Nota nota : notasDisponibles) { if (acorde.indexOf(nota.getNombre().substring(0, 1)) > -1) { result.add(nota); } } return result; }
public static void aplicarAlteraciones(String tonalidad, Nota[] notas) { String alteracion; if ("C".equals(tonalidad)) return; else if ("F".equals(tonalidad) || tonalidad.charAt(tonalidad.length() - 1) == 'b') alteracion = "b"; else alteracion = "#"; List<String> notasAlteradas = alteraciones.get(tonalidad); for (Nota nota : notas) { if (notasAlteradas.indexOf(nota.getNombre()) != -1) nota.setNombre(nota.getNombre() + alteracion); } }
public String getNotaRecuperacaoFinal(int idUsuario) { String strNota = ""; for (int i = 0; i < getListNota().size(); i++) { Nota nota = getListNota().get(i); if (nota.getNota() != null && !nota.getNota().isEmpty()) { if (idUsuario == nota.getIdUsuario()) { strNota = nota.getNota(); } } } return strNota; }