-# -*- encoding: utf8 -*-
+# -*- coding: utf-8 -*-
def note2midi(note):
" convert note name to midi note number, e.g. [C-1, G9] -> [0, 127] "
_valid_notenames = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
_valid_modifiers = {None: 0, u'♮': 0, '#': +1, u'♯': +1, u'\udd2a': +2, 'b': -1, u'♭': -1, u'\ufffd': -2}
- _valid_octaves = range(-1, 10)
+ _valid_octaves = range(-1, 10)
if type(note) not in (str, unicode):
raise TypeError, "a string is required, got %s" % note
if not (1 < len(note) < 5):
-# -*- encoding: utf8 -*-
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
from aubio import midi2note
import unittest
( 127, 'G9' ),
)
-class TestMidi2NoteGoodValues(unittest.TestCase):
+class midi2note_good_values(unittest.TestCase):
def test_midi2note_known_values(self):
" known values are correctly converted "
for midi, note in list_of_known_midis:
self.assertEqual ( midi2note(midi), note )
-class TestNote2MidiWrongValues(unittest.TestCase):
+class midi2note_wrong_values(unittest.TestCase):
def test_midi2note_negative_value(self):
" fails when passed a negative value "
-# -*- encoding: utf8 -*-
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
from aubio import note2midi
import unittest
( u'A♮2', 45 ),
)
-class TestNote2MidiGoodValues(unittest.TestCase):
+class note2midi_good_values(unittest.TestCase):
def test_note2midi_known_values(self):
" known values are correctly converted "
for note, midi in list_of_known_notes:
self.assertEqual ( note2midi(note), midi )
-class TestNote2MidiWrongValues(unittest.TestCase):
+class note2midi_wrong_values(unittest.TestCase):
def test_note2midi_missing_octave(self):
" fails when passed only one character"