Changeset 40136171 for python/lib/aubio
- Timestamp:
- Oct 29, 2018, 11:54:28 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
- Children:
- 4afeac2
- Parents:
- cc3f129
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/aubio/midiconv.py
rcc3f129 r40136171 25 25 _valid_octaves = range(-1, 10) 26 26 if not isinstance(note, str_instances): 27 raise TypeError("a string is required, got %s (%s)" % (note, str(type(note)))) 27 msg = "a string is required, got {:s} ({:s})" 28 raise TypeError(msg.format(str(type(note)), repr(note))) 28 29 if len(note) not in range(2, 5): 29 raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \30 %(len(note), note))30 msg = "string of 2 to 4 characters expected, got {:d} ({:s})" 31 raise ValueError(msg.format(len(note), note)) 31 32 notename, modifier, octave = [None]*3 32 33 … … 52 53 raise ValueError("%s is not a valid octave" % octave) 53 54 54 midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier] 55 midi = 12 + octave * 12 + _valid_notenames[notename] \ 56 + _valid_modifiers[modifier] 55 57 if midi > 127: 56 58 raise ValueError("%s is outside of the range C-2 to G8" % note) … … 62 64 raise TypeError("an integer is required, got %s" % midi) 63 65 if midi not in range(0, 128): 64 raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi) 65 _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'] 66 msg = "an integer between 0 and 127 is excepted, got {:d}" 67 raise ValueError(msg.format(midi)) 68 _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 69 'A', 'A#', 'B'] 66 70 return _valid_notenames[midi % 12] + str(int(midi / 12) - 1) 67 71
Note: See TracChangeset
for help on using the changeset viewer.