[py] midi2note rounds to nearest integer midi note
authorPaul Brossier <piem@piem.org>
Mon, 29 Oct 2018 22:55:51 +0000 (23:55 +0100)
committerPaul Brossier <piem@piem.org>
Mon, 29 Oct 2018 22:55:51 +0000 (23:55 +0100)
python/lib/aubio/midiconv.py

index d3dc554..2161afe 100644 (file)
@@ -72,4 +72,5 @@ def midi2note(midi):
 def freq2note(freq):
     " convert frequency in Hz to nearest note name, e.g. [0, 22050.] -> [C-1, G9] "
     from aubio import freqtomidi
-    return midi2note(int(freqtomidi(freq)))
+    nearest_note = int(freqtomidi(freq) + .5)
+    return midi2note(nearest_note)