private void mapNoteNames() { for (int i = 1; i < 12; i++) { for (NoteReference note : NoteReference.values()) { int noteNumber = note.getBaseNumber() + (octave[i] * 12); noteNameMap.put(note.getBaseName() + range[i], noteNumber); } } }
/* * method to create a map of Note numbers to Note Names Numbers * to get a note number out of the map use something like: * String[] noteNumberArray = midiNote.getNoteNumberArray(); * println(noteNumberArray[60]); * println(noteNumberArray[2]); * println(noteNumberArray[127]); * * Intentionally using a simple array here for performance reasons */ private void mapNoteNumbers() { String noteName; int octaveValue; for (int i = 1; i < 11; i++) { octaveValue = octave[i] * 12; for (NoteReference note : NoteReference.values()) { // if the note name contains a "flat" then it has the identical note number // as the previous flat, decrement the total note number count and insert into // the array a string made up of both the previous notes name and the current one if (note.getBaseName().contains("b")) { String previous = noteNumberArray[note.getBaseNumber() + octaveValue]; noteName = previous + "/" + note.getBaseName() + range[i]; } else { noteName = note.getBaseName() + range[i]; } noteNumberArray[note.getBaseNumber() + octaveValue] = noteName; } } }