All,
Not sure if this is the best way to do this, but here is a simple method to create a map of midi note numbers to their equal-tempered counterparts:
Code:
private Map<String, Integer> mapNotes(){
Map<String, Integer> noteMap = new HashMap<String, Integer>();
String[] noteNames =
{"C","C#","Db","D","D#","Eb","E","F","F#","Gb","G","G#","Ab","A","A#","Bb","B"};
for (int noteNumber=0; noteNumber<128;){
for (Integer range=-1; range<10; range++){
for (String nextNote : noteNames){
if (nextNote.contains("b")) noteNumber--;
noteMap.put(nextNote + range.toString(), noteNumber);
noteNumber++;
}
}
}
return noteMap;
}
This was written in eclipse, so mileage may vary in the PDE, you may need to tweak the method definition. This is a simple way to map these values, then pull them out via note name, rather than having to look at a midi implementation guide to get the correct note number for the note you want.