shithub: aubio

Download patch

ref: cefa29d8bedf7cd205b18f793a487f9e6e1cd3d3
parent: 7be77bb824974e41d749cb1c34eab75ed586730c
parent: 27ed546f53a56f83e3e678c040d6eadd11b1965f
author: Paul Brossier <piem@piem.org>
date: Tue Oct 30 06:24:08 EDT 2018

Merge branch 'feature/note2freq'

--- a/python/tests/test_note2midi.py
+++ b/python/tests/test_note2midi.py
@@ -3,7 +3,7 @@
 
 from __future__ import unicode_literals
 
-from aubio import note2midi, freq2note, note2freq
+from aubio import note2midi, freq2note, note2freq, float_type
 from nose2.tools import params
 import unittest
 
@@ -127,7 +127,10 @@
 
     def test_note2freq_under(self):
         " make sure note2freq(A4) == 440"
-        self.assertEqual(440, note2freq("A4"))
+        if float_type == 'float32':
+            self.assertEqual(440, note2freq("A4"))
+        else:
+            self.assertLess(abs(note2freq("A4")-440), 1.e-12)
 
 if __name__ == '__main__':
     import nose2
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -522,7 +522,7 @@
   if (freq < 2. || freq > 100000.) return 0.; // avoid nans and infs
   /* log(freq/A-2)/log(2) */
   midi = freq / 6.875;
-  midi = LOG (midi) / 0.69314718055995;
+  midi = LOG (midi) / 0.6931471805599453;
   midi *= 12;
   midi -= 3;
   return midi;
@@ -534,7 +534,7 @@
   smpl_t freq;
   if (midi > 140.) return 0.; // avoid infs
   freq = (midi + 3.) / 12.;
-  freq = EXP (freq * 0.69314718055995);
+  freq = EXP (freq * 0.6931471805599453);
   freq *= 6.875;
   return freq;
 }