title: Convert Midi Note Numbers To Name and Octave
body: <p>Does anybody know of anything that exists in the Java world to map midi note numbers to specific note names and octave numbers.  For example, see the reference table:</p>
  
  <p><a href="http://www.harmony-central.com/MIDI/Doc/table2.html" rel="noreferrer">http://www.harmony-central.com/MIDI/Doc/table2.html</a></p>
  
  <p>I want to map a midi note number 60 to it's corresponding note name (MiddleC) in octave 4.  I could write a utility class/enum for this, but it would be rather tedious.  Does anybody know of anything?</p>
  
  <p>I'm specifically using this to write a Tenori-On/Monome clone in Java, so far so good...</p>
  
  <p><strong>Solution</strong></p>
  
  <p>This was what I ended up using:</p>
  
  <pre><code>String[] noteString = new String[] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
  
  int octave = (initialNote / 12) - 1;
  int noteIndex = (initialNote % 12);
  String note = noteString[noteIndex];
  </code></pre>