Great start. You could definitely get a more musical sound out of it by mapping it onto a scale rather than just the full range of MIDI notes. Also, this approach operates on fixed note lengths--another interesting idea might be to use one of the compared numbers to determine note length rather than a second pitch.